PIbd-23 Gutorov I.A. Second LabWork #3
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user