public void GetReferencedDocuments_WriteOffTest() { var interactive = Substitute.For <IInteractiveQuestion>(); interactive.Question(string.Empty).ReturnsForAnyArgs(true); var baseParameters = Substitute.For <BaseParameters>(); using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var warehouse = new Warehouse(); uow.Save(warehouse); var nomenclatureType = new ItemsType { Name = "Тестовый тип номенклатуры" }; uow.Save(nomenclatureType); var nomenclature = new Nomenclature { Type = nomenclatureType }; uow.Save(nomenclature); var employee = new EmployeeCard(); uow.Save(employee); var expense = new Expense { Date = new DateTime(2021, 9, 10), Employee = employee, Operation = ExpenseOperations.Employee, Warehouse = warehouse, }; var size = new Size(); var height = new Size(); uow.Save(size); uow.Save(height); var stockPosition = new StockPosition(nomenclature, 0, size, height); var item = expense.AddItem(stockPosition, 10); expense.UpdateOperations(uow, baseParameters, interactive); uow.Save(expense); //Списываем 3 штуки var writeoff = new Writeoff() { Date = new DateTime(2021, 9, 11), }; var writeoffItem = writeoff.AddItem(item.EmployeeIssueOperation, 2); writeoff.UpdateOperations(uow); uow.Save(writeoff); uow.Commit(); var repository = new EmployeeIssueRepository(uow); var result = repository.GetReferencedDocuments(writeoffItem.EmployeeWriteoffOperation.Id); Assert.That(result.First().DocumentType, Is.EqualTo(StokDocumentType.WriteoffDoc)); Assert.That(result.First().DocumentId, Is.EqualTo(writeoff.Id)); Assert.That(result.First().ItemId, Is.EqualTo(writeoffItem.Id)); } }
public void UpdateOperations_WarehouseOperation_CanChangeWearPercentTest() { var uow = Substitute.For <IUnitOfWork>(); var nomeclature = Substitute.For <Nomenclature>(); var warehouse = Substitute.For <Warehouse>(); var position = new StockPosition(nomeclature, 0.2m, new Size(), new Size()); var writeoff = new Writeoff { Date = new DateTime(2019, 1, 15) }; writeoff.AddItem(position, warehouse, 2); Assert.That(writeoff.Items[0].WearPercent, Is.EqualTo(0.2m)); //Меняем значение процента износа writeoff.Items[0].WearPercent = 2; //Выполняем writeoff.UpdateOperations(uow); Assert.That(writeoff.Items[0].WearPercent, Is.EqualTo(2)); }
public void UpdateOperations_EmployeeIssueOperation_CanChangeWearPercentTest() { var uow = Substitute.For <IUnitOfWork>(); var nomeclature = Substitute.For <Nomenclature>(); var employee = Substitute.For <EmployeeCard>(); var issueOperation = new EmployeeIssueOperation { OperationTime = new DateTime(2019, 1, 1), StartOfUse = new DateTime(2019, 1, 1), Issued = 10, Nomenclature = nomeclature, WearPercent = 0, ExpiryByNorm = new DateTime(2019, 1, 15), Employee = employee }; var writeoff = new Writeoff { Date = new DateTime(2019, 1, 15) }; writeoff.AddItem(issueOperation, 2); Assert.That(writeoff.Items[0].WearPercent, Is.EqualTo(1)); //Меняем значение процента износа writeoff.Items[0].WearPercent = 2; //Выполняем writeoff.UpdateOperations(uow); Assert.That(writeoff.Items[0].WearPercent, Is.EqualTo(2)); }
public void WriteoffMainTest() { var ask = Substitute.For <IInteractiveQuestion>(); ask.Question(string.Empty).ReturnsForAnyArgs(true); var baseParameters = Substitute.For <BaseParameters>(); using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var warehouse = new Warehouse(); uow.Save(warehouse); var nomenclatureType = new ItemsType { Name = "Тестовый тип номенклатуры" }; uow.Save(nomenclatureType); var nomenclature = new Nomenclature { Type = nomenclatureType }; uow.Save(nomenclature); var size = new Size(); var height = new Size(); uow.Save(size); uow.Save(height); var position1 = new StockPosition(nomenclature, 0, size, height); var protectionTools = new ProtectionTools { Name = "СИЗ для тестирования" }; protectionTools.AddNomeclature(nomenclature); uow.Save(protectionTools); var employee = new EmployeeCard(); uow.Save(employee); uow.Commit(); var income = new Income { Warehouse = warehouse, Date = new DateTime(2017, 1, 1), Operation = IncomeOperations.Enter }; var incomeItem1 = income.AddItem(nomenclature); incomeItem1.Amount = 10; income.UpdateOperations(uow, ask); uow.Save(income); var expense = new Expense { Operation = ExpenseOperations.Employee, Warehouse = warehouse, Employee = employee, Date = new DateTime(2018, 10, 22) }; var item = expense.AddItem(position1, 3); //Обновление операций expense.UpdateOperations(uow, baseParameters, ask); uow.Save(expense); uow.Commit(); var balance = EmployeeRepository.ItemsBalance(uow, employee, new DateTime(2018, 10, 30)); Assert.That(balance.First().Amount, Is.EqualTo(3)); //Списываем var writeoff = new Writeoff { Date = new DateTime(2018, 10, 25) }; writeoff.AddItem(item.EmployeeIssueOperation, 1); //Обновление операций writeoff.UpdateOperations(uow); uow.Save(writeoff); uow.Commit(); var balanceAfter = EmployeeRepository.ItemsBalance(uow, employee, new DateTime(2018, 10, 30)); Assert.That(balanceAfter.First().Amount, Is.EqualTo(2)); } }