/// <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 ValidatedBodCommand_Command_Should_ValidatedBodCommand_Type() { await Task.Run(() => { Item items = new Item(); ValidatedBodCommand result = new ValidatedBodCommand(items); Assert.IsType <ValidatedBodCommand>(result); }); }
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 ItShouldCallMediatorSendMethodExactlyOnceWhenExecuteStrategyCalled() { await Task.Run(() => { Item item = new Item() { ItemPath = "Inbound/path", ItemId = "location" }; ValidatedBodCommand command = new ValidatedBodCommand(item); _mockMediator.Setup(x => x.Send(command, new System.Threading.CancellationToken())) .Returns(Task.FromResult(new BusinessValidationProxy())); IBusinessValidationStrategy bodStrategy = new BodStrategy(_mockMediator.Object); Task <BusinessValidationProxy> result = bodStrategy.ExecuteStrategy(string.Empty, item); _mockMediator.Verify( v => v.Send(It.IsAny <ValidatedBodCommand>(), It.IsAny <CancellationToken>()) , Times.Exactly(1)); }); }