|
|
|
@@ -16,51 +16,51 @@ internal class PostDataModelTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void IdIsNullOrEmptyTest()
|
|
|
|
public void IdIsNullOrEmptyTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel("0", Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel("0", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
post = CreateDataModel(string.Empty, "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void IdIsNotGuidTest()
|
|
|
|
public void IdIsNotGuidTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel("id", Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel("id", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void PostIdIsNullEmptyTest()
|
|
|
|
public void PostIdIsNullEmptyTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), null, "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel("0", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
post = CreateDataModel("0", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void PostIdIsNotGuidTest()
|
|
|
|
public void PostIdIsNotGuidTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), "postId", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel("0", "name", PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void PostNameIsEmptyTest()
|
|
|
|
public void PostNameIsEmptyTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), null, PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, PostType.Waiter, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void PostTypeIsNoneTest()
|
|
|
|
public void PostTypeIsNoneTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void SalaryIsLessOrZeroTest()
|
|
|
|
public void SalaryIsLessOrZeroTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.Waiter, 0, true, DateTime.UtcNow);
|
|
|
|
var post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.Waiter, 0, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.Waiter, -10, true, DateTime.UtcNow);
|
|
|
|
post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.Waiter, -10, true, DateTime.UtcNow);
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
@@ -73,7 +73,7 @@ internal class PostDataModelTests
|
|
|
|
var salary = 10;
|
|
|
|
var salary = 10;
|
|
|
|
var isActual = false;
|
|
|
|
var isActual = false;
|
|
|
|
var changeDate = DateTime.UtcNow.AddDays(-1);
|
|
|
|
var changeDate = DateTime.UtcNow.AddDays(-1);
|
|
|
|
var post = CreateDataModel(postId, postPostId, postName, postType, salary, isActual, changeDate);
|
|
|
|
var post = CreateDataModel(postId, postName, postType, salary, isActual, changeDate);
|
|
|
|
Assert.That(() => post.Validate(), Throws.Nothing);
|
|
|
|
Assert.That(() => post.Validate(), Throws.Nothing);
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -83,7 +83,7 @@ internal class PostDataModelTests
|
|
|
|
Assert.That(post.Salary, Is.EqualTo(salary));
|
|
|
|
Assert.That(post.Salary, Is.EqualTo(salary));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static PostDataModel CreateDataModel(string? id, string? postId, string? postName, PostType postType, double salary, bool isActual, DateTime changeDate) => new(id, postId, postName, postType, salary, isActual, changeDate);
|
|
|
|
private static PostDataModel CreateDataModel(string? id, string? postName, PostType postType, double salary, bool isActual, DateTime changeDate) => new(id, postName, postType, salary, isActual, changeDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|