public void Place_NotHaveError() { // Arrange Guid id = Guid.NewGuid(); var unitUnderTest = new UpdateGarmentComodityPriceCommand() { Date = DateTimeOffset.Now, Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Items = new List <GarmentComodityPriceItemValueObject>() { new GarmentComodityPriceItemValueObject() { Comodity = new GarmentComodity() { Id = 1, Code = "Code", Name = "Name" }, IsValid = true, NewPrice = 1, Price = 1, Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Date = DateTimeOffset.Now.AddDays(-2), Id = id } } }; unitUnderTest.SetIdentity(id); var validator = GetValidationRules(); // Action var result = validator.TestValidate(unitUnderTest); // Assert result.ShouldNotHaveError(); }
public async Task Handle_StateUnderTest_ExpectedBehavior() { // Arrange Guid id = Guid.NewGuid(); UpdateGarmentComodityPriceCommandHandler unitUnderTest = CreateUpdateGarmentComodityPriceCommandHandler(); CancellationToken cancellationToken = CancellationToken.None; UpdateGarmentComodityPriceCommand request = new UpdateGarmentComodityPriceCommand() { Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" }, Date = DateTimeOffset.Now, Items = new List <GarmentComodityPriceItemValueObject>() { new GarmentComodityPriceItemValueObject() { Id = id, IsValid = true, Comodity = new GarmentComodity() { Id = 1, Code = "Code", Name = "Name" }, Date = DateTimeOffset.Now, NewPrice = 2, Price = 2, Unit = new UnitDepartment() { Id = 1, Code = "Code", Name = "Name" } } } }; request.SetIdentity(id); GarmentComodityPrice garmentComodityPrice = new GarmentComodityPrice(id, true, DateTimeOffset.Now, new UnitDepartmentId(1), "unitCode", "unitName", new GarmentComodityId(1), "comodityCode", "comodityName", 1); _mockComodityPriceRepository .Setup(s => s.Query) .Returns(new List <GarmentComodityPriceReadModel>() { garmentComodityPrice.GetReadModel() }.AsQueryable()); _mockComodityPriceRepository .Setup(s => s.Update(It.IsAny <GarmentComodityPrice>())) .Returns(Task.FromResult(It.IsAny <GarmentComodityPrice>())); _MockStorage .Setup(x => x.Save()) .Verifiable(); // Act var result = await unitUnderTest.Handle(request, cancellationToken); // Assert result.Should().NotBeNull(); result.Count().Should().BeGreaterThan(0); }