public async Task <IActionResult> Delete(string id)
        {
            Guid guid = Guid.Parse(id);

            VerifyUser();

            RemoveGarmentFinishingOutCommand command = new RemoveGarmentFinishingOutCommand(guid);
            var order = await Mediator.Send(command);

            return(Ok(order.Identity));
        }
예제 #2
0
        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();
        }