Esempio n. 1
0
        public void CreateCampaign_Command_ShouldBe_Throw_Exception_When_ProductNotExists()
        {
            _productRepositoryMock.Setup(x => x.AnyAsync(It.IsAny <Expression <Func <ProductEntity, bool> > >()))
            .ReturnsAsync(false);

            Assert.ThrowsAsync <ProductNotFoundException>(async() =>
            {
                await _handler.Handle(_createCampaignCommandFaker.Generate(), CancellationToken.None);
            }).Wait();
        }
        public void CreateCampaignHandlerData_ShouldbeTrue_WhenCreated()
        {
            IRepository <Campaigning>       repository = new Mock <IRepository <Campaigning> >().Object;
            ILogger <CreateCampaignHandler> logger     = new Mock <ILogger <CreateCampaignHandler> >().Object;
            IMediator mediator = new Mock <IMediator>().Object;

            CreateCampaignHandler campaignHandler = new CreateCampaignHandler(repository, logger, mediator);

            var result = campaignHandler.Handle(new Dtos.Requests.CreateCampaignRequest {
                CampaignName = "C1", ProductCode = "P1", Duration = 5, Limit = 10, TargetSalesCount = 10
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Data);
        }