public async Task ItShouldReturnTrueWhenNoWaringCheckFails() { await Task.Run(() => { List <Netbsad> netbsads = _mockData.GetNetbsads(); netbsads[0].SettlementPeriod = 30; Item item = new Item() { ItemPath = "Inbound_Netbsad / SAA - I00G - Netbsad / 2018 / 11 / 26 / Netbsad.json", ItemLocation = "location", ItemId = "NETBSAD" }; ValidatedNetbsadCommand command = new ValidatedNetbsadCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Item.ItemPath, command.Item.ItemId)).Returns(Task.FromResult(netbsads)); _mockWriter.Setup(s => s.UpLoadFile(netbsads, "")).Returns(Task.CompletedTask); ValidatedNetbsadCommandHandler commandHandler = new ValidatedNetbsadCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object); BusinessValidationProxy result = commandHandler.Handle(command, new CancellationToken() { }).Result; Assert.True(result.Valid); }); }
public async Task Should_RegisterSubscription_On_Passing_ParameterValues() { BusinessValidationProxy businessValidationProxy = await _mockData.BusinessValidationProxies(); mediatorMock.Setup(x => x.Send(It.IsAny <IRequest <BusinessValidationProxy> >(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(businessValidationProxy)); receiveManagerMock.Setup(r => r.Receive <MessageProcessResponse>(default, default)).Returns(Task.FromResult(MessageProcessResponse.Complete));
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); }
/// <summary> /// The ExecuteStrategy /// </summary> /// <param name="FlowName">The FlowName<see cref="string"/></param> /// <param name="item">The item<see cref="Item"/></param> /// <returns>The <see cref="Task{BusinessValidationProxy}"/></returns> async Task<BusinessValidationProxy> IBusinessValidationStrategy.ExecuteStrategy(string FlowName, Item item) { ValidatedBodCommand validatedBodCommand = new ValidatedBodCommand(item); Log.Information(BusinessValidationConstants.MSG_BUSINESSVALIDATIONSTARTED); BusinessValidationProxy businessValidationProxy = await mediator.Send(validatedBodCommand); return businessValidationProxy; }
public async Task ValidatedBodCommandHandler_Handle_Should_Return_False_When_WaringCheck_IsFalse() { System.Collections.Generic.List <Fpn> fpns = _mockData.GetFpns(); System.Collections.Generic.List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); fpns[0].TimeFrom = new DateTime(2018, 11, 10, 1, 00, 00); fpns[1].TimeFrom = new DateTime(2018, 11, 10, 1, 30, 00); Item item = new Item() { ItemPath = "Inbound/SAA-I003-FPN/2018/10/24/29/FPN/PN.json", ItemId = "FPN" }; string blobName = "Processing/SAA-I003-FPN/2018/11/10/3/FPN/PN.json"; ValidatedFpnCommand command = new ValidatedFpnCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Items.ItemPath, command.Items.ItemId)).Returns(Task.FromResult(fpns)); _mockQuery.Setup(s => s.ExistsAsync(blobName)).Returns(Task.FromResult(true)); _mockQuery.Setup(s => s.GetBmuParticipationAsync(fpns.FirstOrDefault().TimeFrom, fpns.FirstOrDefault().TimeTo)).Returns(Task.FromResult(bmuUnit)); _mockWriter.Setup(s => s.UpLoadFile(fpns, "")).Returns(Task.CompletedTask); ValidatedFpnCommandHandler commandHandler = new ValidatedFpnCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object); BusinessValidationProxy result = await commandHandler.Handle(command, new CancellationToken() { }); Assert.False(result.ValidationResult); }
/// <summary> /// The ExecuteStrategy /// </summary> /// <param name="FlowName">The FlowName<see cref="string"/></param> /// <param name="item">The item<see cref="Item"/></param> /// <returns>The <see cref="Task{BusinessValidationProxy}"/></returns> async Task <BusinessValidationProxy> IBusinessValidationStrategy.ExecuteStrategy(string FlowName, Item item) { Guard.AgainstNull(nameof(item), item); ValidatedBoalfCommand validatedBoalfCommand = new ValidatedBoalfCommand(item); Log.Information(BusinessValidationConstants.MSG_BUSINESSVALIDATIONSTARTED); BusinessValidationProxy businessValidationProxy = await mediator.Send(validatedBoalfCommand); return(businessValidationProxy); }
public async Task ItShouldReturnFalseWhenNoRecordFound() { await Task.Run(() => { List <Netbsad> netbsads = new List <Netbsad>(); Item item = new Item() { ItemPath = "Inbound/path", ItemLocation = "location" }; ValidatedNetbsadCommand command = new ValidatedNetbsadCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Item.ItemPath, command.Item.ItemLocation)).Returns(Task.FromResult(netbsads)); _mockWriter.Setup(s => s.UpLoadFile(netbsads, "")).Returns(Task.CompletedTask); ValidatedNetbsadCommandHandler commandHandler = new ValidatedNetbsadCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object); BusinessValidationProxy result = commandHandler.Handle(command, new CancellationToken() { }).Result; Assert.False(result.InValid); }); }
public async Task ValidatedBodCommandHandler_Handle_Should_Return_False_When_ErrorCheck_RuleSet_IsFail() { System.Collections.Generic.List <Bod> bods = _mockData.GetBods(); System.Collections.Generic.List <ParticipantEnergyAsset> bmuUnit = _mockData.GetBMUParticipant(); bods.FirstOrDefault().TimeFrom = new DateTime(2018, 12, 10, 0, 00, 00); bods.FirstOrDefault().TimeTo = new DateTime(2018, 12, 10, 0, 30, 00); Item item = new Item() { ItemPath = "Inbound/SAA-I003-BOD/2018/10/24/29/BOD/BOD_Data.json", ItemId = "BOD" }; ValidatedBodCommand command = new ValidatedBodCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Items.ItemPath, command.Items.ItemId)).Returns(Task.FromResult(bods)); _mockQuery.Setup(s => s.GetBmuParticipationAsync(bods.FirstOrDefault().TimeFrom, bods.FirstOrDefault().TimeTo)).Returns(Task.FromResult(bmuUnit)); _mockWriter.Setup(s => s.UpLoadFile(bods, "")).Returns(Task.CompletedTask); ValidatedBodCommandHandler commandHandler = new ValidatedBodCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object); BusinessValidationProxy result = await commandHandler.Handle(command, new CancellationToken() { }); Assert.False(result.ValidationResult); }
public async Task ValidatedBoalfCommandHandler_Handle_Should_Return_False_When_No_Record_To_Validate() { await Task.Run(() => { List <Boalf> boalf = new List <Boalf>(); List <ParticipantEnergyAsset> participant = new List <ParticipantEnergyAsset>(); Item item = new Item() { ItemPath = "Inbound/path", ItemId = "location" }; ValidatedBoalfCommand command = new ValidatedBoalfCommand(item); _mockQuery.Setup(s => s.GetListAsync(command.Items.ItemPath, command.Items.ItemId)).Returns(Task.FromResult(boalf)); _mockQuery.Setup(s => s.GetBmuParticipationAsync(DateTime.Now, DateTime.Now)).Returns(Task.FromResult(participant)); _mockWriter.Setup(s => s.UpLoadFile(boalf, "")).Returns(Task.CompletedTask); ValidatedBoalfCommandHandler commandHandler = new ValidatedBoalfCommandHandler(_mockQuery.Object, _mockApplicationBuilder.Object, _mockFileProcessorService.Object); BusinessValidationProxy result = commandHandler.Handle(command, new CancellationToken() { }).Result; Assert.False(result.ValidationResult); }); }