public async Task FpnValidator_Validate_Should_Return_True_When_TimeTo_ThereFor_SameBmUnitRecord() { await Task.Run(() => { //Arrange List <Fpn> fpns = new List <Fpn>(); Fpn fpn = _mockData.GetFpns().FirstOrDefault(); List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); fpn.TimeFrom = new DateTime(2018, 11, 10, 1, 00, 00); fpn.TimeTo = new DateTime(2018, 11, 10, 1, 30, 00); fpns.Add(fpn); Aggregate <Fpn> aggregate = new Aggregate <Fpn>(new Item(), fpns, bmuUnit, null); FpnValidator validator = new FpnValidator(); //Act FluentValidation.Results.ValidationResult result = validator.Validate(aggregate, ruleSet: BusinessValidationConstants.WARNINGCHECK); //Assert Assert.True(result.IsValid); }); }
public async Task FpnValidator_Validate_Should_Return_False_When_TimeFrom_IsGreaterThan_TimeTo() { await Task.Run(() => { //Arrange List <Fpn> fpns = new List <Fpn>(); Fpn fpn = _mockData.GetFpns().FirstOrDefault(); List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); fpn.TimeFrom = new DateTime(2018, 11, 10, 1, 30, 00); fpn.TimeTo = new DateTime(2018, 11, 10, 1, 00, 00); fpns.Add(fpn); Aggregate <Fpn> aggregate = new Aggregate <Fpn>(new Item(), fpns, bmuUnit, null); FpnValidator validator = new FpnValidator(); //Act FluentValidation.Results.ValidationResult result = validator.Validate(aggregate, ruleSet: BusinessValidationConstants.WARNINGCHECK); //Assert Assert.False(result.IsValid); Assert.Equal(result.Errors.FirstOrDefault().ToString(), BusinessValidationConstants.MSG_TOTIMEGREATERTHANFROMTIME); }); }