Compare commits
1 Commits
Task_1_Mod
...
Task_1_Mod
| Author | SHA1 | Date | |
|---|---|---|---|
| c2d9ff6ca2 |
@@ -0,0 +1,33 @@
|
|||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using SmallSoftwareContracts.Extensions;
|
||||||
|
using SmallSoftwareContracts.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareContracts.DataModels;
|
||||||
|
|
||||||
|
public class StorageDataModel(string id, string storageName, string address, bool isDeleted, List<StorageSoftwareDataModel> softwares) : IValidation
|
||||||
|
{
|
||||||
|
public string Id { get; private set; } = id;
|
||||||
|
public string StorageName { get; private set; } = storageName;
|
||||||
|
public string Address { get; private set; } = address;
|
||||||
|
public bool IsDeleted { get; private set; } = isDeleted;
|
||||||
|
public List<StorageSoftwareDataModel> Softwares { get; private set; } = softwares;
|
||||||
|
|
||||||
|
public void Validate()
|
||||||
|
{
|
||||||
|
if (Id.IsEmpty())
|
||||||
|
throw new ValidationException("Field Id is empty");
|
||||||
|
if (!Id.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||||
|
if (StorageName.IsEmpty())
|
||||||
|
throw new ValidationException("Field StorageName is empty");
|
||||||
|
if (Address.IsEmpty())
|
||||||
|
throw new ValidationException("Field Address is empty");
|
||||||
|
if ((Softwares?.Count ?? 0) == 0)
|
||||||
|
throw new ValidationException("The sale must include products");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using SmallSoftwareContracts.Extensions;
|
||||||
|
using SmallSoftwareContracts.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareContracts.DataModels;
|
||||||
|
|
||||||
|
public class StorageSoftwareDataModel(string storageId, string softwareId, int count) : IValidation
|
||||||
|
{
|
||||||
|
public string StorageId { get; private set; } = storageId;
|
||||||
|
public string SoftwareId { get; private set; } = softwareId;
|
||||||
|
public int Count { get; private set; } = count;
|
||||||
|
public void Validate()
|
||||||
|
{
|
||||||
|
if (StorageId.IsEmpty())
|
||||||
|
throw new ValidationException("Field StorageId is empty");
|
||||||
|
if (!StorageId.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field StorageId is not a unique identifier");
|
||||||
|
if (SoftwareId.IsEmpty())
|
||||||
|
throw new ValidationException("Field SoftwareId is empty");
|
||||||
|
if (!SoftwareId.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field SoftwareId is not a unique identifier");
|
||||||
|
if (Count <= 0)
|
||||||
|
throw new ValidationException("Field Count is less than or equal to 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using SmallSoftwareContracts.Extensions;
|
||||||
|
using SmallSoftwareContracts.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareContracts.DataModels;
|
||||||
|
|
||||||
|
public class SupplyDataModel(string id, string storageId, DateTime supplyDate, List<SupplySoftwareDataModel> softwares) : IValidation
|
||||||
|
{
|
||||||
|
public string Id { get; private set; } = id;
|
||||||
|
public string StorageId { get; private set; } = storageId;
|
||||||
|
public DateTime SupplyDate { get; private set; } = supplyDate;
|
||||||
|
|
||||||
|
public List<SupplySoftwareDataModel> Softwares { get; private set; } = softwares;
|
||||||
|
|
||||||
|
public void Validate()
|
||||||
|
{
|
||||||
|
if (Id.IsEmpty())
|
||||||
|
throw new ValidationException("Field Id is empty");
|
||||||
|
if (!Id.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||||
|
if (StorageId.IsEmpty())
|
||||||
|
throw new ValidationException("Field StorageId is empty");
|
||||||
|
if (!StorageId.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field StorageId is not a unique identifier");
|
||||||
|
|
||||||
|
if ((Softwares?.Count ?? 0) == 0)
|
||||||
|
throw new ValidationException("The sale must include products");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using SmallSoftwareContracts.Extensions;
|
||||||
|
using SmallSoftwareContracts.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareContracts.DataModels;
|
||||||
|
|
||||||
|
public class SupplySoftwareDataModel(string supplyId, string softwareId, int count) : IValidation
|
||||||
|
{
|
||||||
|
public string SupplyId { get; private set; } = supplyId;
|
||||||
|
public string SoftwareId { get; private set; } = softwareId;
|
||||||
|
public int Count { get; private set; } = count;
|
||||||
|
public void Validate()
|
||||||
|
{
|
||||||
|
if (SupplyId.IsEmpty())
|
||||||
|
throw new ValidationException("Field SupplyId is empty");
|
||||||
|
if (!SupplyId.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field SupplyId is not a unique identifier");
|
||||||
|
if (SoftwareId.IsEmpty())
|
||||||
|
throw new ValidationException("Field SoftwareId is empty");
|
||||||
|
if (!SoftwareId.IsGuid())
|
||||||
|
throw new ValidationException("The value in the field SoftwareId is not a unique identifier");
|
||||||
|
if (Count <= 0)
|
||||||
|
throw new ValidationException("Field Count is less than or equal to 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using SmallSoftwareContracts.DataModels;
|
||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareTests.DataModelsTests;
|
||||||
|
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class StorageDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storage = CreateDataModel(null, "StorageName", "Address", false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storage = CreateDataModel(string.Empty, "StorageName", "Address", false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var storage = CreateDataModel("invalid-id", "StorageName", "Address", false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StorageNameIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storage = CreateDataModel(Guid.NewGuid().ToString(), null, "Address", false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storage = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "Address", false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddressIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storage = CreateDataModel(Guid.NewGuid().ToString(), "StorageName", null, false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storage = CreateDataModel(Guid.NewGuid().ToString(), "StorageName", string.Empty, false, CreateSoftwarees());
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SoftwaresIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storage = CreateDataModel(Guid.NewGuid().ToString(), "StorageName", "Address", false, null);
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storage = CreateDataModel(Guid.NewGuid().ToString(), "StorageName", "Address", false, []);
|
||||||
|
Assert.That(() => storage.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsAreCorrectTest()
|
||||||
|
{
|
||||||
|
var storageId = Guid.NewGuid().ToString();
|
||||||
|
var storageName = "StorageName";
|
||||||
|
var address = "Address";
|
||||||
|
var isDeleted = false;
|
||||||
|
var softwares = CreateSoftwarees();
|
||||||
|
|
||||||
|
var storage = CreateDataModel(storageId, storageName, address, isDeleted, softwares);
|
||||||
|
|
||||||
|
Assert.That(() => storage.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(storage.Id, Is.EqualTo(storageId));
|
||||||
|
Assert.That(storage.StorageName, Is.EqualTo(storageName));
|
||||||
|
Assert.That(storage.Address, Is.EqualTo(address));
|
||||||
|
Assert.That(storage.IsDeleted, Is.EqualTo(isDeleted));
|
||||||
|
Assert.That(storage.Softwares, Is.EquivalentTo(softwares));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StorageDataModel CreateDataModel(string? id, string? storageName, string? address, bool isDeleted,
|
||||||
|
List<StorageSoftwareDataModel> softwares)
|
||||||
|
{
|
||||||
|
return new StorageDataModel(id, storageName, address, isDeleted, softwares);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<StorageSoftwareDataModel> CreateSoftwarees() => [new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 1)];
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
using SmallSoftwareContracts.DataModels;
|
||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareTests.DataModelsTests;
|
||||||
|
[TestFixture]
|
||||||
|
internal class StorageSoftwareDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void StorageIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storageSoftware = CreateDataModel(null, Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storageSoftware = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StorageIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var storageSoftware = CreateDataModel("invalid-storage-id", Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SoftwareIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var storageSoftware = CreateDataModel(Guid.NewGuid().ToString(), null, 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storageSoftware = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SoftwareIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var storageSoftware = CreateDataModel(Guid.NewGuid().ToString(), "invalid-software-id", 10);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CountIsLessOrEqualToZeroTest()
|
||||||
|
{
|
||||||
|
var storageSoftware = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
storageSoftware = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -5);
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsAreCorrectTest()
|
||||||
|
{
|
||||||
|
var storageId = Guid.NewGuid().ToString();
|
||||||
|
var softwareId = Guid.NewGuid().ToString();
|
||||||
|
var count = 10;
|
||||||
|
|
||||||
|
var storageSoftware = CreateDataModel(storageId, softwareId, count);
|
||||||
|
|
||||||
|
Assert.That(() => storageSoftware.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(storageSoftware.StorageId, Is.EqualTo(storageId));
|
||||||
|
Assert.That(storageSoftware.SoftwareId, Is.EqualTo(softwareId));
|
||||||
|
Assert.That(storageSoftware.Count, Is.EqualTo(count));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StorageSoftwareDataModel CreateDataModel(string? storageId, string? softwareId, int count)
|
||||||
|
{
|
||||||
|
return new StorageSoftwareDataModel(storageId, softwareId, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using SmallSoftwareContracts.DataModels;
|
||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareTests.DataModelsTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class SupplyDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var supply = CreateDataModel(null, Guid.NewGuid().ToString(), DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
supply = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var supply = CreateDataModel("invalid-id", Guid.NewGuid().ToString(), DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StorageIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var supply = CreateDataModel(Guid.NewGuid().ToString(), null, DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
supply = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StorageIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var supply = CreateDataModel(Guid.NewGuid().ToString(), "invalid-storage-id", DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SupplyIngredientsIsEmptyTest()
|
||||||
|
{
|
||||||
|
var supply = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.UtcNow, new List<SupplySoftwareDataModel>());
|
||||||
|
Assert.That(() => supply.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsAreCorrectTest()
|
||||||
|
{
|
||||||
|
var supplyId = Guid.NewGuid().ToString();
|
||||||
|
var storageId = Guid.NewGuid().ToString();
|
||||||
|
var supplyDate = DateTime.UtcNow;
|
||||||
|
var supplySoftwarees = new List<SupplySoftwareDataModel>
|
||||||
|
{
|
||||||
|
new SupplySoftwareDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10)
|
||||||
|
};
|
||||||
|
|
||||||
|
var supply = CreateDataModel(supplyId, storageId, supplyDate, supplySoftwarees);
|
||||||
|
|
||||||
|
Assert.That(() => supply.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(supply.Id, Is.EqualTo(supplyId));
|
||||||
|
Assert.That(supply.StorageId, Is.EqualTo(storageId));
|
||||||
|
Assert.That(supply.SupplyDate, Is.EqualTo(supplyDate));
|
||||||
|
Assert.That(supply.Softwares, Is.EqualTo(supplySoftwarees));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SupplyDataModel CreateDataModel(string? id, string? storageId, DateTime supplyDate, List<SupplySoftwareDataModel> supplySoftwarees)
|
||||||
|
{
|
||||||
|
return new SupplyDataModel(id, storageId, supplyDate, supplySoftwarees);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
using SmallSoftwareContracts.DataModels;
|
||||||
|
using SmallSoftwareContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SmallSoftwareTests.DataModelsTests;
|
||||||
|
[TestFixture]
|
||||||
|
public class SupplySoftwareDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void SupplyIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var supplySoftware = CreateDataModel(null, Guid.NewGuid().ToString(), 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
supplySoftware = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SupplyIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var supplySoftware = CreateDataModel("invalid-id", Guid.NewGuid().ToString(), 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SoftwareIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var supplySoftware = CreateDataModel(Guid.NewGuid().ToString(), null, 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
supplySoftware = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SoftwareIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var supplySoftware = CreateDataModel(Guid.NewGuid().ToString(), "invalid-id", 5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CountIsLessThanOrEqualToZeroTest()
|
||||||
|
{
|
||||||
|
var supplySoftware = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
|
||||||
|
supplySoftware = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -5);
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsAreCorrectTest()
|
||||||
|
{
|
||||||
|
var supplyId = Guid.NewGuid().ToString();
|
||||||
|
var softwareId = Guid.NewGuid().ToString();
|
||||||
|
var count = 10;
|
||||||
|
|
||||||
|
var supplySoftware = CreateDataModel(supplyId, softwareId, count);
|
||||||
|
|
||||||
|
Assert.That(() => supplySoftware.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(supplySoftware.SupplyId, Is.EqualTo(supplyId));
|
||||||
|
Assert.That(supplySoftware.SoftwareId, Is.EqualTo(softwareId));
|
||||||
|
Assert.That(supplySoftware.Count, Is.EqualTo(count));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SupplySoftwareDataModel CreateDataModel(string storageId, string softwareId, int count)
|
||||||
|
{
|
||||||
|
return new SupplySoftwareDataModel(storageId, softwareId, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user