public async Task ValidatedBoalfCommandHandler_Handle_Should_Return_False_When_WaringCheck_IsFalse() { List <Boalf> boalfs = _mockData.GetBoalfs().Take(1).ToList(); List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); List <BoalfIndexTable> boalfIndexTable = _mockData.GetUpdateorINSForFileProcess(); boalfs[0].DeemedBidOfferFlag = "FALSE"; boalfs[0].SoFlag = "FALSE"; boalfs[0].AmendmentFlag = "FALSE"; boalfs[0].StorFlag = "FALSE"; boalfs[0].TimeFrom = DateTime.Now; boalfs[0].TimeTo = DateTime.Now; Item item = new Item() { ItemPath = "Test/SAA-I00V-Boalf/2018/10/24/29/Boalf/BOALF.json", ItemId = "BOALF" }; ValidatedBoalfCommand command = new ValidatedBoalfCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Items.ItemPath, command.Items.ItemId)).Returns(Task.FromResult(boalfs)); _mockQuery.Setup(s => s.GetBmuParticipationAsync(boalfs.FirstOrDefault().TimeFrom, boalfs.FirstOrDefault().TimeTo)).Returns(Task.FromResult(bmuUnit)); _mockWriter.Setup(s => s.UpLoadFile(boalfs, "")).Returns(Task.CompletedTask); _mockQuery.Setup(s => s.GetListBoalfIndexTable(boalfs.FirstOrDefault().BmuName, boalfs.FirstOrDefault().BidOfferAcceptanceNumber.ToString(), boalfs.FirstOrDefault().AcceptanceTime.ToString("yyyy-MM-dd HH:mm"))).Returns(Task.FromResult(boalfIndexTable)); ValidatedBoalfCommandHandler commandHandler = new ValidatedBoalfCommandHandler(_mockQuery.Object, _mockApplicationBuilder.Object, _mockFileProcessorService.Object); BusinessValidationProxy result = await commandHandler.Handle(command, new CancellationToken() { }); Assert.False(result.ValidationResult); }
public async Task FileProcessService_FileProcess_Should_Return_Complete_When_FirstTimeInsert() { await Task.Run(() => { List <Boalf> boalfs = _mockData.GetFileProcessData().Take(2).ToList(); List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); List <BoalfIndexTable> updateOrInsFlow = new List <BoalfIndexTable>(); List <Boalf> blobBoalfData = new List <Boalf>(); Item item1 = new Item { ItemPath = "Processing/BOALF/2018/4/9/1/BOALF.json", ItemId = "BOALFS" }; Aggregate <Boalf> aggregate = new Aggregate <Boalf>(item1, boalfs, bmuUnit, updateOrInsFlow); aggregate.ValidFlow.AddRange(aggregate.BusinessValidationFlow); aggregate.InValidFlow.AddRange(_mockData.GetFileProcessDataRejectedAcceptance()); aggregate.SettlementDuration = 30; _mockWriter.Setup(s => s.UpLoadFile(aggregate, "")).Returns(Task.CompletedTask); _mockQuery.Setup(s => s.GetListAsync(item1.ItemPath, "BOALFS")).Returns(Task.FromResult(blobBoalfData)); FileProcessService fileProcess = new FileProcessService(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object); Task result = fileProcess.FileProcess(aggregate); Assert.True(result.IsCompleted); }); }
public async Task boalfValidator_Validate_Should_Return_True_When_TimeFrom_IsLessThan_TimeTo() { await Task.Run(() => { //Arrange List <Boalf> boalfs = new List <Boalf>(); Boalf boalf = _mockData.GetBoalfs().FirstOrDefault(); List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); List <BoalfIndexTable> updateOrInsFlow = _mockData.GetUpdateorINSFlow(); boalf.TimeFrom = new DateTime(2018, 04, 09, 14, 00, 00); boalf.TimeTo = new DateTime(2018, 04, 09, 14, 30, 00); boalfs.Add(boalf); Aggregate <Boalf> aggregate = new Aggregate <Boalf>(new Item(), boalfs, bmuUnit, updateOrInsFlow); BoalfValidator Validator = new BoalfValidator(); //Act FluentValidation.Results.ValidationResult result = Validator.Validate(aggregate, ruleSet: BusinessValidationConstants.WARNINGCHECK); //Assert Assert.True(result.IsValid); }); }