Yuna/Yuna.Tests/Repositories/PropRepositoriesTests.cs

83 lines
2.2 KiB
C#

using Yuna.Website.Server.Infrastructure;
using Yuna.Website.Server.Model;
using Yuna.Website.Server.Storage;
using Yuna.Website.Server.Storage.Repositories.Prop;
using Xunit;
namespace Yuna.Tests.Repositories
{
public class PropRepositoriesTests
{
[Fact]
public async Task Create_Creates_Prop()
{
// Arrange
Settings.Init();
var _context = new DapperContext(true);
var repo = new PropRepository(_context);
// Act
Prop prop = new()
{
JsonValueName = "test",
MeasureName = "test",
Name = "test",
};
var result = await repo.Create(prop);
// Assert
Assert.NotNull(result);
Assert.Equal(result.Name, prop.Name);
Assert.Equal(result.MeasureName, prop.MeasureName);
Assert.Equal(result.JsonValueName, prop.JsonValueName);
}
[Fact]
public async Task GetById_Gets_PropWithId()
{
// Arrange
Settings.Init();
var _context = new DapperContext(true);
var repo = new PropRepository(_context);
// Act
var result = await repo.GetById(1);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Id);
}
[Fact]
public async Task GetByPropName_Gets_PropWithName()
{
// Arrange
Settings.Init();
var _context = new DapperContext(true);
var repo = new PropRepository(_context);
// Act
var result = await repo.GetByPropName("test");
// Assert
Assert.NotNull(result);
Assert.Equal("test", result.Name);
}
[Fact]
public async Task GetList_Gets_List()
{
// Arrange
Settings.Init();
var _context = new DapperContext(true);
var repo = new PropRepository(_context);
// Act
var result = await repo.GetList();
// Assert
Assert.NotNull(result);
Assert.NotEmpty(result);
}
}
}