public void Place_HaveError() { // Arrange var validator = GetValidationRules(); var unitUnderTest = new PlaceGarmentCuttingOutCommand(); // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public void Place_HaveError_Date() { // Arrange var validator = GetValidationRules(); var unitUnderTest = new PlaceGarmentCuttingOutCommand(); unitUnderTest.CuttingOutDate = DateTimeOffset.Now.AddDays(-7); unitUnderTest.CuttingInDate = DateTimeOffset.Now; // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public async Task <IActionResult> Post([FromBody] PlaceGarmentCuttingOutCommand command) { try { VerifyUser(); var order = await Mediator.Send(command); return(Ok(order.Identity)); } catch (Exception e) { throw e; } }
public void Place_NotHaveError() { // Arrange Guid id = Guid.NewGuid(); var unitUnderTest = new PlaceGarmentCuttingOutCommand() { Article = "Article", RONo = "RONo", Unit = new Domain.Shared.ValueObjects.UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Comodity = new GarmentComodity() { Id = 1, Code = "Code", Name = "Name" }, CutOutNo = "CutOutNo", CuttingOutDate = DateTimeOffset.Now, CuttingInDate = DateTimeOffset.Now, CuttingOutType = "CuttingOutType", Price = 1, PriceSewing = 1, UnitFrom = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Items = new List <GarmentCuttingOutItemValueObject>() { new GarmentCuttingOutItemValueObject() { Id = id, Details = new List <GarmentCuttingOutDetailValueObject>() { new GarmentCuttingOutDetailValueObject() { BasicPrice = 1, Color = "Color", CutOutItemId = id, CuttingOutQuantity = 1, RemainingQuantity = 2, CuttingOutUom = new Uom() { Id = 1, Unit = "Unit" }, Id = id, Price = 0, Size = new SizeValueObject() { Id = 1, Size = "Size" }, } }, CutOutId = id, CuttingInDetailId = id, CuttingInId = id, DesignColor = "DesignColor", IsSave = true, Product = new Product() { Id = 1, Code = "Code", Name = "Name" }, TotalCuttingOut = 1, TotalCuttingOutQuantity = 1, TotalRemainingQuantityCuttingInItem = 2 } } }; var validator = GetValidationRules(); // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldNotHaveError(); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid cuttingInDetailGuid = Guid.NewGuid(); Guid cuttingInGuid = Guid.NewGuid(); PlaceGarmentCuttingOutCommandHandler unitUnderTest = CreatePlaceGarmentCuttingOutCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; PlaceGarmentCuttingOutCommand placeGarmentCuttingOutCommand = new PlaceGarmentCuttingOutCommand() { RONo = "RONo", UnitFrom = new UnitDepartment(1, "UnitCode", "UnitName"), Comodity = new GarmentComodity(1, "ComoCode", "ComoName"), Unit = new UnitDepartment(1, "UnitCode", "UnitName"), CuttingOutDate = DateTimeOffset.Now, Items = new List <GarmentCuttingOutItemValueObject> { new GarmentCuttingOutItemValueObject { Product = new Product(1, "ProductCode", "ProductName"), CuttingInDetailId = cuttingInDetailGuid, IsSave = true, CuttingInId = cuttingInGuid, Details = new List <GarmentCuttingOutDetailValueObject> { new GarmentCuttingOutDetailValueObject { CuttingOutUom = new Uom(2, "PCS"), CuttingOutQuantity = 1, Size = new SizeValueObject(1, "Size"), Color = "kajsj" } } } }, }; _mockCuttingOutRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingOutReadModel>().AsQueryable()); _mockSewingDORepository .Setup(s => s.Query) .Returns(new List <GarmentSewingDOReadModel>().AsQueryable()); _mockCuttingInDetailRepository .Setup(s => s.Query) .Returns(new List <GarmentCuttingInDetailReadModel> { new GarmentCuttingInDetailReadModel(cuttingInDetailGuid) }.AsQueryable()); GarmentComodityPrice garmentComodity = new GarmentComodityPrice( Guid.NewGuid(), true, DateTimeOffset.Now, new UnitDepartmentId(placeGarmentCuttingOutCommand.Unit.Id), placeGarmentCuttingOutCommand.Unit.Code, placeGarmentCuttingOutCommand.Unit.Name, new GarmentComodityId(placeGarmentCuttingOutCommand.Comodity.Id), placeGarmentCuttingOutCommand.Comodity.Code, placeGarmentCuttingOutCommand.Comodity.Name, 1000 ); _mockComodityPriceRepository .Setup(s => s.Query) .Returns(new List <GarmentComodityPriceReadModel> { garmentComodity.GetReadModel() }.AsQueryable()); _mockCuttingOutRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingOut>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingOut>())); _mockCuttingOutItemRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingOutItem>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingOutItem>())); _mockCuttingOutDetailRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingOutDetail>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingOutDetail>())); _mockCuttingInDetailRepository .Setup(s => s.Update(It.IsAny <GarmentCuttingInDetail>())) .Returns(Task.FromResult(It.IsAny <GarmentCuttingInDetail>())); _mockSewingDORepository .Setup(s => s.Update(It.IsAny <GarmentSewingDO>())) .Returns(Task.FromResult(It.IsAny <GarmentSewingDO>())); _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(placeGarmentCuttingOutCommand, cancellationToken); // Assert result.Should().NotBeNull(); }