Beispiel #1
0
        public async Task ItShouldReturnTrueWhenNoWaringCheckFails()
        {
            await Task.Run(() =>
            {
                List <Disbsad> disbsads      = _mockData.GetDibsads();
                disbsads[0].SettlementPeriod = 30;
                disbsads[1].StorFlag         = "true";

                Item item = new Item()
                {
                    ItemPath     = "Inbound_Disbsad/SAA-I00G-Disbsad/2018/11/26/Disbsad.json",
                    ItemLocation = "location",
                    ItemId       = "DISBSAD"
                };

                ValidatedDisbsadCommand command = new ValidatedDisbsadCommand(item);
                _mockQuery.Setup(s => s.GetListAsync(command.Item.ItemPath, command.Item.ItemId)).Returns(Task.FromResult(disbsads));
                _mockWriter.Setup(s => s.UpLoadFile(disbsads, "")).Returns(Task.CompletedTask);
                ValidatedDisbsadCommandHandler commandHandler = new ValidatedDisbsadCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object);
                BusinessValidationProxy result = commandHandler.Handle(command, new CancellationToken()
                {
                }).Result;

                Assert.True(result.Valid);
            });
        }
 public async Task ItShouldBeValidType()
 {
     await Task.Run(() =>
     {
         Item item = new Item();
         ValidatedDisbsadCommand result = new ValidatedDisbsadCommand(item);
         Assert.IsType <ValidatedDisbsadCommand>(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)
        {
            ValidatedDisbsadCommand validatedNetbsadCommand = new ValidatedDisbsadCommand(item);

            Log.Information(BusinessValidationConstants.MSG_INFO_BUSINESSVALIDATIONPROCESS_STARTED);
            BusinessValidationProxy businessValidationProxy = await mediator.Send(validatedNetbsadCommand);

            return(businessValidationProxy);
        }
Beispiel #4
0
 public async Task ItShouldReturnFalseWhenNoRecordFound()
 {
     await Task.Run(() =>
     {
         List <Disbsad> disbsads = new List <Disbsad>();
         Item item = new Item()
         {
             ItemPath     = "Inbound/path",
             ItemLocation = "location"
         };
         ValidatedDisbsadCommand command = new ValidatedDisbsadCommand(item);
         _mockQuery.Setup(s => s.GetListAsync(command.Item.ItemPath, command.Item.ItemLocation)).Returns(Task.FromResult(disbsads));
         _mockWriter.Setup(s => s.UpLoadFile(disbsads, "")).Returns(Task.CompletedTask);
         ValidatedDisbsadCommandHandler commandHandler = new ValidatedDisbsadCommandHandler(_mockQuery.Object, _mockWriter.Object, _mockApplicationBuilder.Object);
         BusinessValidationProxy result = commandHandler.Handle(command, new CancellationToken()
         {
         }).Result;
         Assert.False(result.InValid);
     });
 }
Beispiel #5
0
        public async Task ItShouldCallMediatorSendMethodExactlyOnceWhenExecuteStrategyCalled()
        {
            await Task.Run(() =>
            {
                Item item = new Item()
                {
                    ItemPath = "Inbound/path",
                    ItemId   = "location"
                };

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

                IBusinessValidationStrategy disbsadStrategy = new DisbsadStrategy(_mockMediator.Object);

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

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