74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
|
using TheCyclopsContracts.DataModels;
|
|||
|
using TheCyclopsContracts.Exceptions;
|
|||
|
|
|||
|
namespace TheCyclopsTests.DataModelsTests;
|
|||
|
|
|||
|
[TestFixture]
|
|||
|
internal class StorageComponentDataModelTests
|
|||
|
{
|
|||
|
[Test]
|
|||
|
public void StorageIdIsNullOrEmptyTest()
|
|||
|
{
|
|||
|
var storageComponent = CreateDataModel(null, Guid.NewGuid().ToString(), 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
|
|||
|
storageComponent = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void StorageIdIsNotGuidTest()
|
|||
|
{
|
|||
|
var storageComponent = CreateDataModel("storageId", Guid.NewGuid().ToString(), 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void ComponentIdIsNullOrEmptyTest()
|
|||
|
{
|
|||
|
var storageComponent = CreateDataModel(Guid.NewGuid().ToString(), null, 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
|
|||
|
storageComponent = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void ComponentIdIsNotGuidTest()
|
|||
|
{
|
|||
|
var storageComponent = CreateDataModel(Guid.NewGuid().ToString(), "componentId", 10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void CountIsLessOrZeroTest()
|
|||
|
{
|
|||
|
var storageComponent = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
|
|||
|
storageComponent = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10);
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.TypeOf<ValidationException>());
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void AllFieldsIsCorrectTest()
|
|||
|
{
|
|||
|
var storageId = Guid.NewGuid().ToString();
|
|||
|
var componentId = Guid.NewGuid().ToString();
|
|||
|
var count = 10;
|
|||
|
var storageComponent = CreateDataModel(storageId, componentId, count);
|
|||
|
|
|||
|
Assert.That(() => storageComponent.Validate(), Throws.Nothing);
|
|||
|
|
|||
|
Assert.Multiple(() =>
|
|||
|
{
|
|||
|
Assert.That(storageComponent.StorageId, Is.EqualTo(storageId));
|
|||
|
Assert.That(storageComponent.ComponentId, Is.EqualTo(componentId));
|
|||
|
Assert.That(storageComponent.Count, Is.EqualTo(count));
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
private static StorageComponentDataModel CreateDataModel(string? storageId, string? componentId, int count) =>
|
|||
|
new(storageId, componentId, count);
|
|||
|
}
|