public void GetCampaignHandler_ShouldGetCampaign() { IQueryable <Campaigning> prd = new List <Campaigning> { new Campaigning { CampaignName = "C1", ProductCode = "P1", Duration = 5, Limit = 10, TargetSalesCount = 10 } }.AsQueryable(); var repoMock = new Mock <IRepository <Campaigning> >(); repoMock.Setup(x => x.GetWhereAsync(It.IsAny <Expression <Func <Campaigning, bool> > >())).Returns <Expression <Func <Campaigning, bool> > >(predicate => Task.FromResult(prd.Where(predicate).ToList().AsEnumerable())); IRepository <Campaigning> repository = repoMock.Object; ILogger <GetCampaignHandler> logger = new Mock <ILogger <GetCampaignHandler> >().Object; IMediator mediator = new Mock <IMediator>().Object; GetCampaignHandler campaignHandler = new GetCampaignHandler(repository, logger); var result = campaignHandler.Handle(new Dtos.Requests.GetCampaignRequest("C1"), new System.Threading.CancellationToken()).Result; Assert.True(result.Data != null); }
public string[] parseInput(String input) { CommandHandler commandHandler; List <string> list = input.Split(' ').ToList(); if (list.Contains(createProduct)) { commandHandler = new CreateProductHandler(); } else if (list.Contains(getProduct)) { commandHandler = new GetProductHandler(); } else if (list.Contains(createOrder)) { commandHandler = new CreateOrderHandler(); } else if (list.Contains(createCampaign)) { commandHandler = new CreateCampaignHandler(); } else if (list.Contains(getCampaign)) { commandHandler = new GetCampaignHandler(); } else if (list.Contains(increaseTime)) { commandHandler = new IncreaseTimeHandler(); } else { return(null); } Console.WriteLine(commandHandler.Execute(list)); return(null); }