|
|
|
|
@@ -4,6 +4,7 @@ using SladkieBulkiBusinessLogic.Implementations;
|
|
|
|
|
using SladkieBulkiContrakts.DataModels;
|
|
|
|
|
using SladkieBulkiContrakts.Enums;
|
|
|
|
|
using SladkieBulkiContrakts.Exceptions;
|
|
|
|
|
using SladkieBulkiContrakts.Infrastructure.PostConfigurations;
|
|
|
|
|
using SladkieBulkiContrakts.StoragesContarcts;
|
|
|
|
|
using SladkieBulkiTests.Infrastructure;
|
|
|
|
|
using System;
|
|
|
|
|
@@ -188,166 +189,166 @@ internal class SalaryBusinessLogicContractTests
|
|
|
|
|
_salaryStorageContract.Verify(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>()), Times.Once);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_CalculateSalary_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// var saleSum = 200.0;
|
|
|
|
|
// var postSalary = 2000.0;
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, saleSum, workerId, null)]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, postSalary));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),]);
|
|
|
|
|
// var sum = 0.0;
|
|
|
|
|
// var expectedSum = postSalary + saleSum * 0.1;
|
|
|
|
|
// _salaryStorageContract.Setup(x => x.AddElement(It.IsAny<SalaryDataModel>()))
|
|
|
|
|
// .Callback((SalaryDataModel x) =>
|
|
|
|
|
// {
|
|
|
|
|
// sum = x.WorkerSalary;
|
|
|
|
|
// });
|
|
|
|
|
// //Act
|
|
|
|
|
// _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
// //Assert
|
|
|
|
|
// Assert.That(sum, Is.EqualTo(expectedSum));
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_CalculateSalary_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
var saleSum = 200.0;
|
|
|
|
|
var postSalary = 2000.0;
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, saleSum, workerId, null)]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new ManufacturerPostConfiguration { Rate = postSalary, SalePercent = 0.1 }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),]);
|
|
|
|
|
var sum = 0.0;
|
|
|
|
|
var expectedSum = postSalary + saleSum * 0.1;
|
|
|
|
|
_salaryStorageContract.Setup(x => x.AddElement(It.IsAny<SalaryDataModel>()))
|
|
|
|
|
.Callback((SalaryDataModel x) =>
|
|
|
|
|
{
|
|
|
|
|
sum = x.WorkerSalary;
|
|
|
|
|
});
|
|
|
|
|
//Act
|
|
|
|
|
_salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.That(sum, Is.EqualTo(expectedSum));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_WithSeveralWorkers_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var worker1Id = Guid.NewGuid().ToString();
|
|
|
|
|
// var worker2Id = Guid.NewGuid().ToString();
|
|
|
|
|
// var worker3Id = Guid.NewGuid().ToString();
|
|
|
|
|
// var list = new List<WorkerDataModel>() {
|
|
|
|
|
// new(worker1Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),
|
|
|
|
|
// new(worker2Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),
|
|
|
|
|
// new(worker3Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")
|
|
|
|
|
// };
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker1Id, null),
|
|
|
|
|
// new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker1Id, null),
|
|
|
|
|
// new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker2Id, null),
|
|
|
|
|
// new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker3Id, null),
|
|
|
|
|
// new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker3Id, null)]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, 2000));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns(list);
|
|
|
|
|
// //Act
|
|
|
|
|
// _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
// //Assert
|
|
|
|
|
// _salaryStorageContract.Verify(x => x.AddElement(It.IsAny<SalaryDataModel>()), Times.Exactly(list.Count));
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_WithSeveralWorkers_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var worker1Id = Guid.NewGuid().ToString();
|
|
|
|
|
var worker2Id = Guid.NewGuid().ToString();
|
|
|
|
|
var worker3Id = Guid.NewGuid().ToString();
|
|
|
|
|
var list = new List<WorkerDataModel>() {
|
|
|
|
|
new(worker1Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),
|
|
|
|
|
new(worker2Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru"),
|
|
|
|
|
new(worker3Id, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")
|
|
|
|
|
};
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker1Id, null),
|
|
|
|
|
new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker1Id, null),
|
|
|
|
|
new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker2Id, null),
|
|
|
|
|
new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker3Id, null),
|
|
|
|
|
new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 0.0, worker3Id, null)]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = 2000 }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns(list);
|
|
|
|
|
//Act
|
|
|
|
|
_salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
//Assert
|
|
|
|
|
_salaryStorageContract.Verify(x => x.AddElement(It.IsAny<SalaryDataModel>()), Times.Exactly(list.Count));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_WithoitSalesByWorker_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var postSalary = 2000.0;
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, postSalary));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
// var sum = 0.0;
|
|
|
|
|
// var expectedSum = postSalary;
|
|
|
|
|
// _salaryStorageContract.Setup(x => x.AddElement(It.IsAny<SalaryDataModel>()))
|
|
|
|
|
// .Callback((SalaryDataModel x) =>
|
|
|
|
|
// {
|
|
|
|
|
// sum = x.WorkerSalary;
|
|
|
|
|
// });
|
|
|
|
|
// //Act
|
|
|
|
|
// _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
// //Assert
|
|
|
|
|
// Assert.That(sum, Is.EqualTo(expectedSum));
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_WithoitSalesByWorker_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var postSalary = 2000.0;
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = postSalary }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
var sum = 0.0;
|
|
|
|
|
var expectedSum = postSalary;
|
|
|
|
|
_salaryStorageContract.Setup(x => x.AddElement(It.IsAny<SalaryDataModel>()))
|
|
|
|
|
.Callback((SalaryDataModel x) =>
|
|
|
|
|
{
|
|
|
|
|
sum = x.WorkerSalary;
|
|
|
|
|
});
|
|
|
|
|
//Act
|
|
|
|
|
_salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow);
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.That(sum, Is.EqualTo(expectedSum));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_SaleStorageReturnNull_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, 2000));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_SaleStorageReturnNull_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = 2000 }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_PostStorageReturnNull_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_PostStorageReturnNull_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_WorkerStorageReturnNull_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, 2000));
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_WorkerStorageReturnNull_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = 2000 }));
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_SaleStorageThrowException_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, 2000));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_SaleStorageThrowException_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = 2000 }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_PostStorageThrowException_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_PostStorageThrowException_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Returns([new WorkerDataModel(workerId, "Test", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false, "1@mail.ru")]);
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[Test]
|
|
|
|
|
//public void CalculateSalaryByMounth_WorkerStorageThrowException_ThrowException_Test()
|
|
|
|
|
//{
|
|
|
|
|
// //Arrange
|
|
|
|
|
// var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
// _productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
// .Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
// _postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
// .Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, 2000));
|
|
|
|
|
// _workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
// .Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
// //Act&Assert
|
|
|
|
|
// Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
//}
|
|
|
|
|
[Test]
|
|
|
|
|
public void CalculateSalaryByMounth_WorkerStorageThrowException_ThrowException_Test()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
var workerId = Guid.NewGuid().ToString();
|
|
|
|
|
_productionStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
|
|
|
|
.Returns([new ProductionDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0, 200.0, workerId, null)]);
|
|
|
|
|
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
|
|
|
|
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Manufacturer, new PostConfiguration() { Rate = 200 }));
|
|
|
|
|
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
|
|
|
|
.Throws(new StorageException(new InvalidOperationException()));
|
|
|
|
|
//Act&Assert
|
|
|
|
|
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|