This commit is contained in:
Ivan Gutorov 2025-02-16 21:30:51 +04:00
parent 7f7cbd26af
commit 3a1b867c29

View File

@ -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);
}