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 ValidatedBoalfCommand_Command_Should_ValidatedBoalfCommand_Type()
 {
     await Task.Run(() =>
     {
         Item items = new Item();
         ValidatedBoalfCommand result = new ValidatedBoalfCommand(items);
         Assert.IsType <ValidatedBoalfCommand>(result);
     });
 }
Beispiel #3
0
        /// <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 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);
            });
        }
        public async Task ItShouldCallMediatorSendMethodExactlyOnceWhenExecuteStrategyCalled()
        {
            await Task.Run(() =>
            {
                Item item = new Item()
                {
                    ItemPath = "Inbound/path",
                    ItemId   = "location"
                };

                ValidatedBoalfCommand command = new ValidatedBoalfCommand(item);
                _mockMediator.Setup(x => x.Send(command, new System.Threading.CancellationToken()))
                .Returns(Task.FromResult(new BusinessValidationProxy()));

                IBusinessValidationStrategy boalfStrategy = new BoalfStrategy(_mockMediator.Object);

                Task <BusinessValidationProxy> result = boalfStrategy.ExecuteStrategy(string.Empty, item);

                _mockMediator.Verify(
                    v => v.Send(It.IsAny <ValidatedBoalfCommand>(), It.IsAny <CancellationToken>())
                    , Times.Exactly(1));
            });
        }