public void Place_NotHaveError() { // Arrange Guid id = Guid.NewGuid(); var unitUnderTest = new UpdateGarmentAvalProductCommand() { Article = "Article", AvalDate = DateTimeOffset.Now, PreparingDate = DateTimeOffset.Now, RONo = "RONo", Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "name" }, Items = new List <GarmentAvalProductItemValueObject>() { new GarmentAvalProductItemValueObject() { APId = Guid.NewGuid(), BasicPrice = 1, DesignColor = "DesignColor", Identity = Guid.NewGuid(), IsReceived = true, PreparingId = new GarmentPreparingId(id.ToString()), PreparingItemId = new GarmentPreparingItemId(id.ToString()), PreparingQuantity = 2, Product = new Domain.GarmentAvalProducts.ValueObjects.Product() { Id = 1, Code = "Code", Name = "Name" }, Quantity = 1, Uom = new Domain.GarmentAvalProducts.ValueObjects.Uom() { Id = 1, Unit = "Unit" } } } }; unitUnderTest.SetId(id); var validator = GetValidationRules(); // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldNotHaveError(); }
public void Place_HaveError() { // Arrange var validator = GetValidationRules(); var unitUnderTest = new UpdateGarmentAvalProductCommand(); // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public void Place_HaveError_Date() { var validator = GetValidationRules(); var unitUnderTest = new UpdateGarmentAvalProductCommand(); unitUnderTest.AvalDate = DateTimeOffset.Now.AddDays(-7); unitUnderTest.PreparingDate = DateTimeOffset.Now; var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid id = Guid.NewGuid(); UpdateGarmentAvalProductCommandHandler unitUnderTest = CreateUpdateGarmentAvalProductCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentAvalProductCommand request = new UpdateGarmentAvalProductCommand() { Article = "Article", AvalDate = DateTimeOffset.Now, Items = new List <GarmentAvalProductItemValueObject>() { new GarmentAvalProductItemValueObject(id, id, new GarmentPreparingId(id.ToString()), new GarmentPreparingItemId(id.ToString()), new Product(), "designColor", 1, new Uom()) { Identity = id, APId = id, PreparingItemId = new GarmentPreparingItemId(id.ToString()), PreparingId = new GarmentPreparingId(id.ToString()), Product = new Product() { Id = 1, Code = "Code", Name = "Name" }, DesignColor = "DesignColor", Quantity = 1, Uom = new Uom() { Id = 1, Unit = "Unit" } } }, RONo = "RONo", Unit = new Domain.Shared.ValueObjects.UnitDepartment(1, "code", "name"), }; request.SetId(id); _mockGarmentAvalProductRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentAvalProductReadModel, bool> > >())) .Returns(new List <GarmentAvalProduct>() { new GarmentAvalProduct(id, "roNo", "article", DateTimeOffset.Now, new Domain.Shared.ValueObjects.UnitDepartmentId(1), "unitCode", "unitName") }); _mockGarmentAvalProductItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentAvalProductItemReadModel, bool> > >())) .Returns(new List <GarmentAvalProductItem>() { new GarmentAvalProductItem(id, id, new GarmentPreparingId(id.ToString()), new GarmentPreparingItemId(id.ToString()), new ProductId(1), "productCode", "productName", "designColor", 1, new UomId(1), "uomUnit", 1, false) }); _mockGarmentAvalProductItemRepository .Setup(s => s.Update(It.IsAny <GarmentAvalProductItem>())) .Returns(Task.FromResult(It.IsAny <GarmentAvalProductItem>())); _mockGarmentAvalProductRepository .Setup(s => s.Update(It.IsAny <GarmentAvalProduct>())) .Returns(Task.FromResult(It.IsAny <GarmentAvalProduct>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); var result = await unitUnderTest.Handle(request, cancellationToken); result.Should().NotBeNull(); // Assert }