示例#1
0
        public async Task Handle_Cutting_ShouldSuccess()
        {
            // Arrange
            PlaceGarmentAvalComponentCommandHandler unitUnderTest = CreatePlaceGarmentAvalComponentCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;

            Guid guid = Guid.NewGuid();

            PlaceGarmentAvalComponentCommand placeGarmentAvalComponentCommand = new PlaceGarmentAvalComponentCommand()
            {
                AvalComponentType = "CUTTING",
                Unit     = new UnitDepartment(1, "UnitCode", "UnitName"),
                Comodity = new GarmentComodity(),
                Items    = new List <PlaceGarmentAvalComponentItemValueObject>
                {
                    new PlaceGarmentAvalComponentItemValueObject
                    {
                        IsSave  = true,
                        Product = new Product(),
                        Size    = new SizeValueObject()
                    }
                }
            };

            _mockGarmentAvalComponentRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentAvalComponentReadModel>().AsQueryable());

            _mockGarmentAvalComponentRepository
            .Setup(s => s.Update(It.IsAny <GarmentAvalComponent>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAvalComponent>()));

            _mockGarmentAvalComponentItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentAvalComponentItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAvalComponentItem>()));

            _mockGarmentCuttingInDetailRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentCuttingInDetailReadModel, bool> > >()))
            .Returns(new List <GarmentCuttingInDetail>()
            {
                new GarmentCuttingInDetail(Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, new ProductId(1), null, null, null, null, 0, new UomId(1), null, 0, new UomId(1), null, 0, 0, 1, 1, null)
            });

            _mockGarmentCuttingInDetailRepository
            .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>()))
            .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>()));

            _MockStorage
            .Setup(x => x.Save())
            .Verifiable();

            // Act
            var result = await unitUnderTest.Handle(placeGarmentAvalComponentCommand, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }
示例#2
0
        public async Task Handle_SewingOutItemNotFound_ShouldError()
        {
            // Arrange
            PlaceGarmentAvalComponentCommandHandler unitUnderTest = CreatePlaceGarmentAvalComponentCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;

            Guid guid = Guid.NewGuid();

            PlaceGarmentAvalComponentCommand placeGarmentAvalComponentCommand = new PlaceGarmentAvalComponentCommand()
            {
                AvalComponentType = "SEWING",
                Unit     = new UnitDepartment(1, "UnitCode", "UnitName"),
                Comodity = new GarmentComodity(),
                Items    = new List <PlaceGarmentAvalComponentItemValueObject>
                {
                    new PlaceGarmentAvalComponentItemValueObject
                    {
                        IsSave  = true,
                        Product = new Product(),
                        Size    = new SizeValueObject()
                    }
                }
            };

            _mockGarmentAvalComponentRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentAvalComponentReadModel>().AsQueryable());

            _mockGarmentAvalComponentItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentAvalComponentItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentAvalComponentItem>()));

            _mockGarmentSewingOutItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentSewingOutItemReadModel, bool> > >()))
            .Returns(new List <GarmentSewingOutItem>());

            // Act
            var result = await Assert.ThrowsAnyAsync <Exception>(async() => await unitUnderTest.Handle(placeGarmentAvalComponentCommand, cancellationToken));

            // Assert
            result.Should().NotBeNull();
        }