public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid finStockGuid = Guid.NewGuid(); Guid exGoodGuid = Guid.NewGuid(); Guid exGoodItemGuid = Guid.NewGuid(); Guid returId = Guid.NewGuid(); Guid returItemId = Guid.NewGuid(); RemoveGarmentExpenditureGoodCommandHandler unitUnderTest = CreateRemoveGarmentExpenditureGoodCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; RemoveGarmentExpenditureGoodCommand RemoveGarmentFinishingOutCommand = new RemoveGarmentExpenditureGoodCommand(exGoodGuid); GarmentExpenditureGood expenditureGood = new GarmentExpenditureGood( exGoodGuid, "no", "export", new UnitDepartmentId(1), "uCode", "Uname", "roNo", "art", new GarmentComodityId(1), "cCode", "cName", new BuyerId(1), "nam", "bCode", DateTimeOffset.Now, "inv", "con", 0, null, false); GarmentFinishedGoodStock garmentFinishedGoodStock = new GarmentFinishedGoodStock(finStockGuid, "no", "ro", "article", expenditureGood.UnitId, expenditureGood.UnitCode, expenditureGood.UnitName, expenditureGood.ComodityId, expenditureGood.ComodityCode, expenditureGood.ComodityName, new SizeId(1), null, new UomId(1), null, 1, 1, 1); GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory(Guid.NewGuid(), garmentFinishedGoodStock.Identity, Guid.Empty, Guid.Empty, exGoodGuid, exGoodItemGuid, Guid.Empty, Guid.Empty, returId, returItemId, null, "ro", "article", expenditureGood.UnitId, expenditureGood.UnitCode, expenditureGood.UnitName, expenditureGood.ComodityId, expenditureGood.ComodityCode, expenditureGood.ComodityName, new SizeId(1), null, new UomId(1), null, 1, 1, 1); _mockFinishedGoodStockRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishedGoodStockReadModel> { garmentFinishedGoodStock.GetReadModel() }.AsQueryable()); _mockExpenditureGoodRepository .Setup(s => s.Query) .Returns(new List <GarmentExpenditureGoodReadModel> { expenditureGood.GetReadModel() }.AsQueryable()); _mockExpenditureGoodItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentExpenditureGoodItemReadModel, bool> > >())) .Returns(new List <GarmentExpenditureGoodItem>() { new GarmentExpenditureGoodItem(exGoodItemGuid, exGoodGuid, finStockGuid, new SizeId(1), null, 1, 0, new UomId(1), null, null, 1, 1) }); //_mockExpenditureGoodItemRepository // .Setup(s => s.Query) // .Returns(new List<GarmentExpenditureGoodItemReadModel> // { // new GarmentExpenditureGoodItemReadModel(exGoodItemGuid) // }.AsQueryable()); _mockFinishedGoodStockHistoryRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishedGoodStockHistoryReadModel> { garmentFinishedGoodStockHistory.GetReadModel() }.AsQueryable()); GarmentComodityPrice garmentComodity = new GarmentComodityPrice( Guid.NewGuid(), true, DateTimeOffset.Now, new UnitDepartmentId(expenditureGood.UnitId.Value), expenditureGood.UnitCode, expenditureGood.UnitName, new GarmentComodityId(expenditureGood.ComodityId.Value), expenditureGood.ComodityCode, expenditureGood.ComodityName, 1000 ); _mockComodityPriceRepository .Setup(s => s.Query) .Returns(new List <GarmentComodityPriceReadModel> { garmentComodity.GetReadModel() }.AsQueryable()); _mockExpenditureGoodRepository .Setup(s => s.Update(It.IsAny <GarmentExpenditureGood>())) .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGood>())); _mockExpenditureGoodItemRepository .Setup(s => s.Update(It.IsAny <GarmentExpenditureGoodItem>())) .Returns(Task.FromResult(It.IsAny <GarmentExpenditureGoodItem>())); _mockFinishedGoodStockRepository .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStock>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStock>())); _mockFinishedGoodStockHistoryRepository .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStockHistory>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStockHistory>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(RemoveGarmentFinishingOutCommand, cancellationToken); // Assert result.Should().NotBeNull(); }
public async Task Handle_StateUnderTest_ExpectedBehavior_GUDANGJADI() { // Arrange Guid finishingInItemGuid = Guid.NewGuid(); Guid finishingOutGuid = Guid.NewGuid(); Guid finishingOutItemGuid = Guid.NewGuid(); Guid finishingOutDetailGuid = Guid.NewGuid(); RemoveGarmentFinishingOutCommandHandler unitUnderTest = CreateRemoveGarmentFinishingOutCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; RemoveGarmentFinishingOutCommand RemoveGarmentFinishingOutCommand = new RemoveGarmentFinishingOutCommand(finishingOutGuid); GarmentFinishingOut garmentFinishingOut = new GarmentFinishingOut( finishingOutGuid, "no", new UnitDepartmentId(1), "uCode", "Uname", "GUDANG JADI", DateTimeOffset.Now, "ro", "article", new UnitDepartmentId(1), "uCode", "Uname", new GarmentComodityId(1), "cCode", "cName", false); _mockFinishingOutRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishingOutReadModel>() { garmentFinishingOut.GetReadModel() }.AsQueryable()); _mockFinishingOutItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentFinishingOutItemReadModel, bool> > >())) .Returns(new List <GarmentFinishingOutItem>() { new GarmentFinishingOutItem(finishingOutItemGuid, finishingOutGuid, Guid.Empty, finishingInItemGuid, new ProductId(1), null, null, null, new SizeId(1), null, 1, new UomId(1), null, null, 1, 1, 1) }); //_mockFinishingOutDetailRepository // .Setup(s => s.Find(It.IsAny<Expression<Func<GarmentFinishingOutDetailReadModel, bool>>>())) // .Returns(new List<GarmentFinishingOutDetail>() // { // new GarmentFinishingOutDetail(Guid.Empty, Guid.Empty,new SizeId(1), null, 1, new UomId(1),null ) // }); _mockFinishingInItemRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishingInItemReadModel> { new GarmentFinishingInItemReadModel(finishingInItemGuid) }.AsQueryable()); GarmentFinishedGoodStock garmentFinishedGoodStock = new GarmentFinishedGoodStock(Guid.NewGuid(), "no", "ro", "article", garmentFinishingOut.UnitId, garmentFinishingOut.UnitCode, garmentFinishingOut.UnitName, garmentFinishingOut.ComodityId, garmentFinishingOut.ComodityCode, garmentFinishingOut.ComodityName, new SizeId(1), null, new UomId(1), null, 1, 1, 1); _mockFinishedGoodStockRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishedGoodStockReadModel> { garmentFinishedGoodStock.GetReadModel() }.AsQueryable()); GarmentFinishedGoodStockHistory garmentFinishedGoodStockHistory = new GarmentFinishedGoodStockHistory(Guid.NewGuid(), garmentFinishedGoodStock.Identity, finishingOutItemGuid, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, null, "ro", "article", garmentFinishingOut.UnitId, garmentFinishingOut.UnitCode, garmentFinishingOut.UnitName, garmentFinishingOut.ComodityId, garmentFinishingOut.ComodityCode, garmentFinishingOut.ComodityName, new SizeId(1), null, new UomId(1), null, 1, 1, 1); _mockFinishedGoodStockHistoryRepository .Setup(s => s.Query) .Returns(new List <GarmentFinishedGoodStockHistoryReadModel> { garmentFinishedGoodStockHistory.GetReadModel() }.AsQueryable()); GarmentComodityPrice garmentComodity = new GarmentComodityPrice( Guid.NewGuid(), true, DateTimeOffset.Now, garmentFinishingOut.UnitId, garmentFinishingOut.UnitCode, garmentFinishingOut.UnitName, garmentFinishingOut.ComodityId, garmentFinishingOut.ComodityCode, garmentFinishingOut.ComodityName, 1000 ); _mockComodityPriceRepository .Setup(s => s.Query) .Returns(new List <GarmentComodityPriceReadModel> { garmentComodity.GetReadModel() }.AsQueryable()); _mockFinishingOutRepository .Setup(s => s.Update(It.IsAny <GarmentFinishingOut>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishingOut>())); _mockFinishingOutItemRepository .Setup(s => s.Update(It.IsAny <GarmentFinishingOutItem>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishingOutItem>())); //_mockFinishingOutDetailRepository // .Setup(s => s.Update(It.IsAny<GarmentFinishingOutDetail>())) // .Returns(Task.FromResult(It.IsAny<GarmentFinishingOutDetail>())); _mockFinishingInItemRepository .Setup(s => s.Update(It.IsAny <GarmentFinishingInItem>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishingInItem>())); _mockFinishedGoodStockRepository .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStock>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStock>())); _mockFinishedGoodStockHistoryRepository .Setup(s => s.Update(It.IsAny <GarmentFinishedGoodStockHistory>())) .Returns(Task.FromResult(It.IsAny <GarmentFinishedGoodStockHistory>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(RemoveGarmentFinishingOutCommand, cancellationToken); // Assert result.Should().NotBeNull(); }