Пример #1
0
        public void Place_ShouldHaveError()
        {
            // Arrange
            var validator     = GetValidationRules();
            var unitUnderTest = new PlaceGarmentSewingInCommand();

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

            // Assert
            result.ShouldHaveError();
        }
Пример #2
0
        public async Task <IActionResult> Post([FromBody] PlaceGarmentSewingInCommand command)
        {
            try
            {
                VerifyUser();

                var order = await Mediator.Send(command);

                return(Ok(order.Identity));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public async Task Post_Throws_Exception()
        {
            // Arrange
            var unitUnderTest = CreateGarmentSewingInController();

            _MockMediator
            .Setup(s => s.Send(It.IsAny <PlaceGarmentSewingInCommand>(), It.IsAny <CancellationToken>()))
            .Throws(new Exception());

            // Act
            var command = new PlaceGarmentSewingInCommand()
            {
                SewingInNo = "SewingInNo",
                Price      = 1
            };
            await Assert.ThrowsAsync <Exception>(() => unitUnderTest.Post(command));
        }
        public async Task Handle_StateUnderTest_ExpectedBehavior_CUTTING()
        {
            // Arrange
            Guid loadingItemGuid   = Guid.NewGuid();
            Guid sewingOutItemGuid = Guid.NewGuid();
            PlaceGarmentSewingInCommandHandler unitUnderTest        = CreatePlaceGarmentSewingInCommandHandler();
            CancellationToken           cancellationToken           = CancellationToken.None;
            PlaceGarmentSewingInCommand placeGarmentSewingInCommand = new PlaceGarmentSewingInCommand()
            {
                RONo         = "RONo",
                Article      = "Article",
                SewingFrom   = "CUTTING",
                UnitFrom     = new UnitDepartment(1, "UnitCode", "UnitName"),
                Unit         = new UnitDepartment(1, "UnitCode", "UnitName"),
                LoadingId    = Guid.NewGuid(),
                LoadingNo    = "LoadingNo",
                SewingInDate = DateTimeOffset.Now,
                Comodity     = new GarmentComodity(1, "ComodityCode", "ComodityName"),
                Items        = new List <GarmentSewingInItemValueObject>
                {
                    new GarmentSewingInItemValueObject
                    {
                        LoadingItemId     = loadingItemGuid,
                        Uom               = new Uom(1, "UomUnit"),
                        Product           = new Product(1, "ProductCode", "ProductName"),
                        Size              = new SizeValueObject(1, "SizeName"),
                        DesignColor       = "DesignColor",
                        Color             = "Color",
                        Quantity          = 1,
                        RemainingQuantity = 1,
                        IsSave            = true
                    }
                },
            };

            _mockSewingInRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingInReadModel>().AsQueryable());

            _mockLoadingItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentLoadingItemReadModel>
            {
                new GarmentLoadingItemReadModel(loadingItemGuid)
            }.AsQueryable());

            _mockSewingInRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingIn>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingIn>()));
            _mockSewingInItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentSewingInItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentSewingInItem>()));
            _mockLoadingItemRepository
            .Setup(s => s.Update(It.IsAny <GarmentLoadingItem>()))
            .Returns(Task.FromResult(It.IsAny <GarmentLoadingItem>()));


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

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

            // Assert
            result.Should().NotBeNull();
        }
Пример #5
0
        public void Place_ShouldNotHaveError()
        {
            // Arrange
            Guid id            = Guid.NewGuid();
            var  unitUnderTest = new PlaceGarmentSewingInCommand()
            {
                Article  = "Article",
                Comodity = new GarmentComodity()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                LoadingId    = id,
                LoadingNo    = "LoadingNo",
                Price        = 1,
                RONo         = "RONo",
                SewingFrom   = "SewingFrom",
                SewingInDate = DateTimeOffset.Now,
                SewingInNo   = "SewingInNo",
                Unit         = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                UnitFrom = new UnitDepartment()
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                Items = new List <GarmentSewingInItemValueObject>()
                {
                    new GarmentSewingInItemValueObject()
                    {
                        BasicPrice           = 1,
                        Color                = "Color",
                        DesignColor          = "DesignColor",
                        FinishingOutDetailId = id,
                        FinishingOutItemId   = id,
                        IsSave               = true,
                        LoadingItemId        = id,
                        Price                = 1,
                        Id      = id,
                        Product = new Product
                        {
                            Id   = 1,
                            Code = "Code",
                            Name = "Name"
                        },
                        Quantity          = 1,
                        RemainingQuantity = 2,
                        SewingInId        = id,
                        SewingOutDetailId = id,
                        SewingOutItemId   = id,
                        Size = new SizeValueObject()
                        {
                            Id   = 1,
                            Size = "Size"
                        },
                        Uom = new Uom()
                        {
                            Id   = 1,
                            Unit = "Unit"
                        }
                    }
                }
            };
            // Action
            var validator = GetValidationRules();
            var result    = validator.TestValidate(unitUnderTest);

            // Assert
            result.ShouldNotHaveError();
        }