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