Merge branch 'Task_1_Models' into Task_2_BusinessLogic

This commit is contained in:
Ivan Gutorov 2025-02-16 22:52:58 +04:00
commit ed32591dd5

View File

@ -9,45 +9,45 @@ internal class InstallationComponentDataModelTests
[Test] [Test]
public void InstallationIdIsNullOrEmptyTest() public void InstallationIdIsNullOrEmptyTest()
{ {
var saleProduct = CreateDataModel(null, Guid.NewGuid().ToString(), 10); var installationComponent = CreateDataModel(null, Guid.NewGuid().ToString(), 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
saleProduct = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10); installationComponent = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
} }
[Test] [Test]
public void InstallationIdIsNotGuidTest() public void InstallationIdIsNotGuidTest()
{ {
var saleProduct = CreateDataModel("installationId", Guid.NewGuid().ToString(), 10); var installationComponent = CreateDataModel("installationId", Guid.NewGuid().ToString(), 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
} }
[Test] [Test]
public void ComponentIdIsNullOrEmptyTest() public void ComponentIdIsNullOrEmptyTest()
{ {
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), null, 10); var installationComponent = CreateDataModel(Guid.NewGuid().ToString(), null, 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
saleProduct = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10); installationComponent = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
} }
[Test] [Test]
public void ComponentIdIsNotGuidTest() public void ComponentIdIsNotGuidTest()
{ {
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), "componentId", 10); var installationComponent = CreateDataModel(Guid.NewGuid().ToString(), "componentId", 10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
} }
[Test] [Test]
public void CountIsLessOrZeroTest() public void CountIsLessOrZeroTest()
{ {
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0); var installationComponent = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10); installationComponent = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10);
Assert.That(() => saleProduct.Validate(), Throws.TypeOf<ValidationException>()); Assert.That(() => installationComponent.Validate(), Throws.TypeOf<ValidationException>());
} }
[Test] [Test]
@ -56,15 +56,15 @@ internal class InstallationComponentDataModelTests
var installationId = Guid.NewGuid().ToString(); var installationId = Guid.NewGuid().ToString();
var componentId = Guid.NewGuid().ToString(); var componentId = Guid.NewGuid().ToString();
var count = 10; var count = 10;
var saleProduct = CreateDataModel(installationId, componentId, count); var installationComponent = CreateDataModel(installationId, componentId, count);
Assert.That(() => saleProduct.Validate(), Throws.Nothing); Assert.That(() => installationComponent.Validate(), Throws.Nothing);
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.That(saleProduct.InstallationId, Is.EqualTo(installationId)); Assert.That(installationComponent.InstallationId, Is.EqualTo(installationId));
Assert.That(saleProduct.ComponentId, Is.EqualTo(componentId)); Assert.That(installationComponent.ComponentId, Is.EqualTo(componentId));
Assert.That(saleProduct.Count, Is.EqualTo(count)); Assert.That(installationComponent.Count, Is.EqualTo(count));
}); });
} }