Files
2025-04-10 09:07:45 +04:00

536 lines
23 KiB
C#

using Microsoft.Extensions.Logging;
using Moq;
using SmallSoftwareBusinessLogic.Implementations;
using SmallSoftwareContracts.DataModels;
using SmallSoftwareContracts.Exceptions;
using SmallSoftwareContracts.StoragesContracts;
namespace SmallSoftwareTests.BusinessLogicsContractsTests;
[TestFixture]
internal class RequestBusinessLogicContractTests
{
private RequestBusinessLogicContract _requestBusinessLogicContract;
private Mock<IRequestStorageContract> _requestStorageContract;
[OneTimeSetUp]
public void OneTimeSetUp()
{
_requestStorageContract = new Mock<IRequestStorageContract>();
_requestBusinessLogicContract = new
RequestBusinessLogicContract(_requestStorageContract.Object, new
Mock<ILogger>().Object);
}
[SetUp]
public void SetUp()
{
_requestStorageContract.Reset();
}
[Test]
public void GetAllRequestsByPeriod_ReturnListOfRecords_Test()
{
//Arrange
var date = DateTime.UtcNow;
var listOriginal = new List<RequestDataModel>()
{
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [new InstallationRequestDataModel(Guid.NewGuid().ToString(),Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow),
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [], DateTime.UtcNow), new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [], DateTime.UtcNow),
};
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>())).Returns(listOriginal);
//Act
var list = _requestBusinessLogicContract.GetAllRequestsByPeriod(date,
date.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Is.EquivalentTo(listOriginal));
_requestStorageContract.Verify(x => x.GetList(date, date.AddDays(1), null, null), Times.Once);
}
[Test]
public void GetAllRequestsByPeriod_ReturnEmptyList_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Returns([]);
//Act
var list =
_requestBusinessLogicContract.GetAllRequestsByPeriod(DateTime.UtcNow,
DateTime.UtcNow.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Has.Count.EqualTo(0));
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public void GetAllRequestsByPeriod_IncorrectDates_ThrowException_Test()
{
//Arrange
var date = DateTime.UtcNow;
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByPeriod(date, date),
Throws.TypeOf<IncorrectDatesException>());
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByPeriod(date, date.AddSeconds(-1)),
Throws.TypeOf<IncorrectDatesException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
}
[Test]
public void GetAllRequestsByPeriod_ReturnNull_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByPeriod(DateTime.UtcNow,
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<NullListException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void GetAllRequestsByPeriod_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByPeriod(DateTime.UtcNow,
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public void GetAllRequestsByWorkerByPeriod_ReturnListOfRecords_Test()
{
//Arrange
var date = DateTime.UtcNow;
var workerId = Guid.NewGuid().ToString();
var listOriginal = new List<RequestDataModel>()
{
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [new InstallationRequestDataModel(Guid.NewGuid().ToString(),Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow),
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [], DateTime.UtcNow), new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [], DateTime.UtcNow),
};
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Returns(listOriginal);
//Act
var list =
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(workerId, date,
date.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Is.EquivalentTo(listOriginal));
_requestStorageContract.Verify(x => x.GetList(date, date.AddDays(1),
workerId, null), Times.Once);
}
[Test]
public void GetAllRequestsByWorkerByPeriod_ReturnEmptyList_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Returns([]);
//Act
var list =
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(Guid.NewGuid().ToString(),
DateTime.UtcNow, DateTime.UtcNow.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Has.Count.EqualTo(0));
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void
GetAllRequestsByWorkerByPeriod_IncorrectDates_ThrowException_Test()
{
//Arrange
var date = DateTime.UtcNow;
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(Guid.NewGuid().ToString(),
date, date), Throws.TypeOf<IncorrectDatesException>());
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(Guid.NewGuid().ToString(),
date, date.AddSeconds(-1)), Throws.TypeOf<IncorrectDatesException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void
GetAllRequestsByWorkerByPeriod_WorkerIdIsNullOrEmpty_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(null, DateTime.UtcNow,
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<ArgumentNullException>());
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(string.Empty,
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<ArgumentNullException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void GetAllRequestsByWorkerByPeriod_WorkerIdIsNotGuid_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod("workerId",
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<ValidationException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void GetAllRequestsByWorkerByPeriod_ReturnNull_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(Guid.NewGuid().ToString(),
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<NullListException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void
GetAllRequestsByWorkerByPeriod_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsByWorkerByPeriod(Guid.NewGuid().ToString(),
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)), Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void GetAllRequestsBySoftwareByPeriod_ReturnListOfRecords_Test()
{
//Arrange
var date = DateTime.UtcNow;
var softwareId = Guid.NewGuid().ToString();
var listOriginal = new List<RequestDataModel>()
{
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [new InstallationRequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow),
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [], DateTime.UtcNow),
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@mail.ru", false, [], DateTime.UtcNow),
};
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Returns(listOriginal);
//Act
var list =
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(softwareId, date,
date.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Is.EquivalentTo(listOriginal));
_requestStorageContract.Verify(x => x.GetList(date, date.AddDays(1), null, softwareId), Times.Once);
}
[Test]
public void GetAllRequestsBySoftwareByPeriod_ReturnEmptyList_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Returns([]);
//Act
var list =
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(Guid.NewGuid().ToString()
, DateTime.UtcNow, DateTime.UtcNow.AddDays(1));
//Assert
Assert.That(list, Is.Not.Null);
Assert.That(list, Has.Count.EqualTo(0));
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void
GetAllRequestsBySoftwareByPeriod_IncorrectDates_ThrowException_Test()
{
//Arrange
var date = DateTime.UtcNow;
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(Guid.NewGuid().ToString()
, date, date), Throws.TypeOf<IncorrectDatesException>());
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(Guid.NewGuid().ToString()
, date, date.AddSeconds(-1)), Throws.TypeOf<IncorrectDatesException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void
GetAllRequestsBySoftwareByPeriod_SoftwareIdIsNullOrEmpty_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(null, DateTime.UtcNow,
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<ArgumentNullException>());
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(string.Empty, DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<ArgumentNullException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void
GetAllRequestsBySoftwareByPeriod_SoftwareIdIsNotGuid_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod("softwareId",
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<ValidationException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Never);
}
[Test]
public void GetAllRequestsBySoftwareByPeriod_ReturnNull_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(Guid.NewGuid().ToString()
, DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<NullListException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void
GetAllRequestsBySoftwareByPeriod_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetAllRequestsBySoftwareByPeriod(Guid.NewGuid().ToString()
, DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
It.IsAny<DateTime?>(), It.IsAny<string>(),
It.IsAny<string>()), Times.Once);
}
[Test]
public void GetRequestByData_GetById_ReturnRecord_Test()
{
//Arrange
var id = Guid.NewGuid().ToString();
var record = new RequestDataModel(id, Guid.NewGuid().ToString(), "test@mail.ru", false, [new InstallationRequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow);
_requestStorageContract.Setup(x =>
x.GetElementById(id)).Returns(record);
//Act
var element = _requestBusinessLogicContract.GetRequestByData(id);
//Assert
Assert.That(element, Is.Not.Null);
Assert.That(element.Id, Is.EqualTo(id));
_requestStorageContract.Verify(x =>
x.GetElementById(It.IsAny<string>()), Times.Once);
}
[Test]
public void GetRequestByData_EmptyData_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.GetRequestByData(null),
Throws.TypeOf<ArgumentNullException>());
Assert.That(() =>
_requestBusinessLogicContract.GetRequestByData(string.Empty),
Throws.TypeOf<ArgumentNullException>());
_requestStorageContract.Verify(x =>
x.GetElementById(It.IsAny<string>()), Times.Never);
}
[Test]
public void GetRequestByData_IdIsNotGuid_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.GetRequestByData("requestId"),
Throws.TypeOf<ValidationException>());
_requestStorageContract.Verify(x =>
x.GetElementById(It.IsAny<string>()), Times.Never);
}
[Test]
public void GetRequestByData_GetById_NotFoundRecord_ThrowException_Test()
{
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetRequestByData(Guid.NewGuid().ToString()),
Throws.TypeOf<ElementNotFoundException>());
_requestStorageContract.Verify(x =>
x.GetElementById(It.IsAny<string>()), Times.Once);
}
[Test]
public void GetRequestByData_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x =>
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.GetRequestByData(Guid.NewGuid().ToString()),
Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x =>
x.GetElementById(It.IsAny<string>()), Times.Once);
}
[Test]
public void InsertRequest_CorrectRecord_Test()
{
//Arrange
var flag = false;
var record = new RequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "valid.email@example.com", false,
[new InstallationRequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow);
_requestStorageContract.Setup(x => x.AddElement(It.IsAny<RequestDataModel>()))
.Callback((RequestDataModel x) =>
{
flag = x.Id == record.Id && x.WorkerId == record.WorkerId && x.IsCancel ==
record.IsCancel && x.Softwares.Count == record.Softwares.Count &&
x.Softwares.First().SoftwareId ==
record.Softwares.First().SoftwareId &&
x.Softwares.First().RequestId ==
record.Softwares.First().RequestId &&
x.Softwares.First().Count ==
record.Softwares.First().Count;
});
//Act
_requestBusinessLogicContract.InsertRequest(record);
//Assert
_requestStorageContract.Verify(x =>
x.AddElement(It.IsAny<RequestDataModel>()), Times.Once);
Assert.That(flag);
}
[Test]
public void InsertRequest_RecordWithExistsData_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x =>
x.AddElement(It.IsAny<RequestDataModel>())).Throws(new
ElementExistsException("Data", "Data"));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.InsertRequest(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@example.com", false,
[new InstallationRequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow)), Throws.TypeOf<ElementExistsException>());
_requestStorageContract.Verify(x => x.AddElement(It.IsAny<RequestDataModel>()), Times.Once);
}
[Test]
public void InsertRequest_NullRecord_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.InsertRequest(null),
Throws.TypeOf<ArgumentNullException>());
_requestStorageContract.Verify(x =>
x.AddElement(It.IsAny<RequestDataModel>()), Times.Never);
}
[Test]
public void InsertRequest_InvalidRecord_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.InsertRequest(new RequestDataModel("id", Guid.NewGuid().ToString(), "test@mail.ru", false, [], DateTime.UtcNow)), Throws.TypeOf<ValidationException>());
_requestStorageContract.Verify(x =>
x.AddElement(It.IsAny<RequestDataModel>()), Times.Never);
}
[Test]
public void InsertRequest_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x =>
x.AddElement(It.IsAny<RequestDataModel>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.InsertRequest(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "test@example.com", false, [new InstallationRequestDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 10)], DateTime.UtcNow)), Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x =>
x.AddElement(It.IsAny<RequestDataModel>()), Times.Once);
}
[Test]
public void CancelRequest_CorrectRecord_Test()
{
//Arrange
var id = Guid.NewGuid().ToString();
var flag = false;
_requestStorageContract.Setup(x => x.DelElement(It.Is((string x) => x ==
id))).Callback(() => { flag = true; });
//Act
_requestBusinessLogicContract.CancelRequest(id);
//Assert
_requestStorageContract.Verify(x => x.DelElement(It.IsAny<string>()),
Times.Once);
Assert.That(flag);
}
[Test]
public void CancelRequest_RecordWithIncorrectId_ThrowException_Test()
{
//Arrange
var id = Guid.NewGuid().ToString();
_requestStorageContract.Setup(x =>
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.CancelRequest(Guid.NewGuid().ToString()),
Throws.TypeOf<ElementNotFoundException>());
_requestStorageContract.Verify(x => x.DelElement(It.IsAny<string>()),
Times.Once);
}
[Test]
public void CancelRequest_IdIsNullOrEmpty_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.CancelRequest(null),
Throws.TypeOf<ArgumentNullException>());
Assert.That(() =>
_requestBusinessLogicContract.CancelRequest(string.Empty),
Throws.TypeOf<ArgumentNullException>());
_requestStorageContract.Verify(x => x.DelElement(It.IsAny<string>()),
Times.Never);
}
[Test]
public void CancelRequest_IdIsNotGuid_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _requestBusinessLogicContract.CancelRequest("id"),
Throws.TypeOf<ValidationException>());
_requestStorageContract.Verify(x => x.DelElement(It.IsAny<string>()),
Times.Never);
}
[Test]
public void CancelRequest_StorageThrowError_ThrowException_Test()
{
//Arrange
_requestStorageContract.Setup(x =>
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new
InvalidOperationException()));
//Act&Assert
Assert.That(() =>
_requestBusinessLogicContract.CancelRequest(Guid.NewGuid().ToString()),
Throws.TypeOf<StorageException>());
_requestStorageContract.Verify(x => x.DelElement(It.IsAny<string>()),
Times.Once);
}
}