Beispiel #1
0
        public void Place_HaveError()
        {
            // Arrange
            var unitUnderTest = new UpdateGarmentLoadingCommand();

            // Action
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldHaveError();
        }
        public async Task <IActionResult> Put(string id, [FromBody] UpdateGarmentLoadingCommand command)
        {
            Guid guid = Guid.Parse(id);

            command.SetIdentity(guid);

            VerifyUser();

            var order = await Mediator.Send(command);

            return(Ok(order.Identity));
        }
Beispiel #3
0
        public void Place_HaveError_Date()
        {
            // Arrange
            var validator     = GetValidationRules();
            var unitUnderTest = new UpdateGarmentLoadingCommand();

            unitUnderTest.LoadingDate  = DateTimeOffset.Now.AddDays(-7);
            unitUnderTest.SewingDODate = DateTimeOffset.Now;

            // Action
            var result = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldHaveError();
        }
Beispiel #4
0
        public void Place_NotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new UpdateGarmentLoadingCommand()
            {
                Article      = "Article",
                LoadingDate  = DateTimeOffset.Now,
                SewingDODate = DateTimeOffset.Now,
                Comodity     = new GarmentComodity()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name",
                },
                LoadingNo  = "LoadingNo",
                RONo       = "RONo",
                SewingDOId = id,
                SewingDONo = "SewingDONo",
                Unit       = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name",
                },
                UnitFrom = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name",
                },
                Items = new List <GarmentLoadingItemValueObject>()
                {
                    new GarmentLoadingItemValueObject()
                    {
                        BasicPrice  = 1,
                        Color       = "Color",
                        DesignColor = "DesignColor",
                        IsSave      = true,
                        LoadingId   = id,
                        Price       = 1,
                        Product     = new Product()
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        },
                        Quantity                  = 1,
                        RemainingQuantity         = 2,
                        SewingDOItemId            = id,
                        SewingDORemainingQuantity = 2,
                        Size = new SizeValueObject()
                        {
                            Id   = 1,
                            Size = "Size"
                        },
                        Uom = new Uom()
                        {
                            Id   = 1,
                            Unit = "unit"
                        }
                    }
                }
            };
            // Act
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldNotHaveError();
        }
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid loadingGuid      = Guid.NewGuid();
            Guid sewingDOItemGuid = Guid.NewGuid();
            Guid sewingDOGuid     = Guid.NewGuid();
            UpdateGarmentLoadingCommandHandler unitUnderTest        = CreateUpdateGarmentLoadingCommandHandler();
            CancellationToken           cancellationToken           = CancellationToken.None;
            UpdateGarmentLoadingCommand UpdateGarmentLoadingCommand = new UpdateGarmentLoadingCommand()
            {
                RONo        = "RONo",
                Unit        = new UnitDepartment(1, "UnitCode", "UnitName"),
                LoadingDate = DateTimeOffset.Now,
                Article     = "Article",
                SewingDOId  = sewingDOGuid,
                UnitFrom    = new UnitDepartment(1, "UnitCode", "UnitName"),
                Comodity    = new GarmentComodity(1, "ComoCode", "ComoName"),
                Items       = new List <GarmentLoadingItemValueObject>
                {
                    new GarmentLoadingItemValueObject
                    {
                        IsSave                    = true,
                        SewingDOItemId            = sewingDOItemGuid,
                        Size                      = new SizeValueObject(1, "Size"),
                        Quantity                  = 1,
                        RemainingQuantity         = 1,
                        SewingDORemainingQuantity = 2,
                        Product                   = new Product(1, "ProdCode", "ProdName"),
                        Uom = new Uom(1, "Uom"),
                    }
                },
            };

            UpdateGarmentLoadingCommand.SetIdentity(loadingGuid);

            _mockLoadingRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentLoadingReadModel>()
            {
                new GarmentLoadingReadModel(loadingGuid)
            }.AsQueryable());
            _mockLoadingItemRepository
            .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentLoadingItemReadModel, bool> > >()))
            .Returns(new List <GarmentLoadingItem>()
            {
                new GarmentLoadingItem(Guid.Empty, Guid.Empty, sewingDOItemGuid, new SizeId(1), null, new ProductId(1), null, null, null, 1, 1, 10, new UomId(1), null, null, 1)
            });

            _mockSewingDOItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingDOItemReadModel>
            {
                new GarmentSewingDOItemReadModel(sewingDOItemGuid)
            }.AsQueryable());

            _mockLoadingRepository
            .Setup(s => s.Update(It.IsAny <GarmentLoading>()))
            .Returns(Task.FromResult(It.IsAny <GarmentLoading>()));
            _mockLoadingItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentLoadingItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentLoadingItem>()));
            _mockSewingDOItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingDOItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingDOItem>()));

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

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

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