PIbd-23 Gutorov I.A. Second LabWork #3
@ -305,15 +305,14 @@ internal class InstallationBusinessLogicContractTest
|
||||
[Test]
|
||||
public void InsertInstallation_CorrectRecord_Test()
|
||||
{
|
||||
//Arrange
|
||||
var flag = false;
|
||||
var record = new InstallationDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.UtcNow, 10, 0, false,
|
||||
var record = new InstallationDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DateTime.UtcNow, 10, 10, false,
|
||||
[new InstallationComponentDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)]);
|
||||
_installationStorageContract.Setup(x => x.AddElement(It.IsAny<InstallationDataModel>()))
|
||||
.Callback((InstallationDataModel x) =>
|
||||
{
|
||||
flag = x.Id == record.Id && x.EmployeeId == record.EmployeeId &&
|
||||
x.InstallationDate == record.InstallationDate && x.Sum == record.Sum &&
|
||||
x.InstallationDate == record.InstallationDate && x.Sum == record.Sum &&
|
||||
x.IsCanceled == record.IsCanceled && x.Components.Count == record.Components.Count &&
|
||||
x.Components.First().ComponentId == record.Components.First().ComponentId &&
|
||||
x.Components.First().InstallationId == record.Components.First().InstallationId &&
|
||||
@ -333,7 +332,7 @@ internal class InstallationBusinessLogicContractTest
|
||||
_installationStorageContract.Setup(x => x.AddElement(It.IsAny<InstallationDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
//Act&Assert
|
||||
Assert.That(() => _installationBusinessLogicContract.InsertInstallation(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
DateTime.UtcNow, 10, 0, false, [new InstallationComponentDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<ElementExistsException>());
|
||||
DateTime.UtcNow, 10, 10, false, [new InstallationComponentDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<ElementExistsException>());
|
||||
_installationStorageContract.Verify(x => x.AddElement(It.IsAny<InstallationDataModel>()), Times.Once);
|
||||
}
|
||||
|
||||
@ -360,7 +359,7 @@ internal class InstallationBusinessLogicContractTest
|
||||
_installationStorageContract.Setup(x => x.AddElement(It.IsAny<InstallationDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
//Act&Assert
|
||||
Assert.That(() => _installationBusinessLogicContract.InsertInstallation(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
DateTime.UtcNow, 10, 0, false, [new InstallationComponentDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<StorageException>());
|
||||
DateTime.UtcNow, 10, 10, false, [new InstallationComponentDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<StorageException>());
|
||||
_installationStorageContract.Verify(x => x.AddElement(It.IsAny<InstallationDataModel>()), Times.Once);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user