public void Place_HaveError() { // Arrange var unitUnderTest = new UpdateGarmentPreparingCommand(); // Action var validator = GetValidationRules(); var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public void Place_NotHaveError() { // Arrange Guid id = Guid.NewGuid(); var unitUnderTest = new UpdateGarmentPreparingCommand() { Article = "Article", IsCuttingIn = true, ProcessDate = DateTimeOffset.Now, ExpenditureDate = DateTimeOffset.Now, RONo = "RONo", UENId = 1, UENNo = "UENNo", Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Items = new List <GarmentPreparingItemValueObject>() { new GarmentPreparingItemValueObject() { BasicPrice = 1, DesignColor = "DesignColor", FabricType = "FabricType", GarmentPreparingId = id, Product = new Product() { Id = 1, Code = "Code", Name = "Name" }, Quantity = 1, RemainingQuantity = 2, UENItemId = 1, Uom = new Uom() { Id = 1, Unit = "Unit" } } } }; // Act var validator = GetValidationRules(); var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldNotHaveError(); }
public void Place_HaveError_Date() { // Arrange var validator = GetValidationRules(); var unitUnderTest = new UpdateGarmentPreparingCommand(); unitUnderTest.ProcessDate = DateTimeOffset.Now.AddDays(-7); unitUnderTest.ExpenditureDate = DateTimeOffset.Now; // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldHaveError(); }
public async Task Handle_PreparingNotFound_Error() { // Arrange Guid preparingGuid = Guid.NewGuid(); UpdateGarmentPreparingCommandHandler unitUnderTest = CreateUpdateGarmentPreparingCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentPreparingCommand UpdateGarmentPreparingCommand = new UpdateGarmentPreparingCommand(); UpdateGarmentPreparingCommand.SetId(preparingGuid); _mockPreparingRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentPreparingReadModel, bool> > >())) .Returns(new List <GarmentPreparing>()); // Act var result = await Assert.ThrowsAnyAsync <Exception>(async() => await unitUnderTest.Handle(UpdateGarmentPreparingCommand, cancellationToken)); // Assert result.Should().NotBeNull(); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid preparingGuid = Guid.NewGuid(); UpdateGarmentPreparingCommandHandler unitUnderTest = CreateUpdateGarmentPreparingCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentPreparingCommand UpdateGarmentPreparingCommand = new UpdateGarmentPreparingCommand() { UENId = 1, UENNo = "test", RONo = "RONo", Unit = new UnitDepartment(1, "UnitCode", "UnitName"), Article = "Test", ProcessDate = DateTimeOffset.Now, IsCuttingIn = false, Items = new List <GarmentPreparingItemValueObject> { new GarmentPreparingItemValueObject { UENItemId = 1, Product = new Product(1, "ProductCode", "ProductName"), DesignColor = "test", Quantity = 1, Uom = new Uom(1, "UomUnit"), FabricType = "Test", RemainingQuantity = 1, BasicPrice = 1, } }, }; UpdateGarmentPreparingCommand.SetId(preparingGuid); _mockPreparingRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentPreparingReadModel, bool> > >())) .Returns(new List <GarmentPreparing>() { new GarmentPreparing(preparingGuid, 1, null, new UnitDepartmentId(1), null, null, DateTimeOffset.Now, null, null, true, new Domain.Shared.ValueObjects.BuyerId(1), null, null) }); _mockPreparingItemRepository .Setup(s => s.Find(It.IsAny <Expression <Func <GarmentPreparingItemReadModel, bool> > >())) .Returns(new List <GarmentPreparingItem>() { new GarmentPreparingItem(Guid.Empty, 0, new ProductId(1), null, null, null, 0, new UomId(1), null, null, 0, 0, Guid.Empty, null) }); _mockPreparingRepository .Setup(s => s.Update(It.IsAny <GarmentPreparing>())) .Returns(Task.FromResult(It.IsAny <GarmentPreparing>())); _mockPreparingItemRepository .Setup(s => s.Update(It.IsAny <GarmentPreparingItem>())) .Returns(Task.FromResult(It.IsAny <GarmentPreparingItem>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(UpdateGarmentPreparingCommand, cancellationToken); // Assert result.Should().NotBeNull(); }