Exemple #1
0
    public void check_create(String campaign1, String campaign2)
    {
        PoolManager poolManager = new PoolManager();

        String[] sCamp        = campaign1.Split(" ");
        String[] sCamp2       = campaign2.Split(" ");
        Campaign campaignTemp = new Campaign(sCamp[1], sCamp[2],
                                             Double.Parse(sCamp[3]), Double.Parse(sCamp[4]), Double.Parse(sCamp[5]));
        Campaign campaignTemp2 = new Campaign(sCamp2[1], sCamp2[2],
                                              Double.Parse(sCamp2[3]), Double.Parse(sCamp2[4]), Double.Parse(sCamp2[5]));

        campaignController.Create(sCamp, poolManager);
        campaignController.Create(sCamp2, poolManager);
        Assert.Equal(2, (int)poolManager.getCampaigns().Count);
    }
 public void CreateReturnsCorrectViewWithCorrectViewModel()
 {
     var mockMediator = new Mock<IMediator>();
     CampaignController controller = new CampaignController(mockMediator.Object, null);
     ViewResult view = (ViewResult) controller.Create();
     CampaignSummaryModel viewModel = (CampaignSummaryModel)view.ViewData.Model;
     Assert.Equal(view.ViewName, "Edit");
     Assert.NotNull(viewModel);
 }
Exemple #3
0
        public void CreateReturnsCorrectViewWithCorrectViewModel()
        {
            var sut  = new CampaignController(null, null);
            var view = (ViewResult)sut.Create();

            var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;

            Assert.Equal("Edit", view.ViewName);
            Assert.NotNull(viewModel);
        }
Exemple #4
0
        public void CreateReturnsCorrectDataOnViewModel()
        {
            var dateTimeNow = DateTime.Now;

            var sut = new CampaignController(null, null)
            {
                DateTimeNow = () => dateTimeNow
            };
            var view      = (ViewResult)sut.Create();
            var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;

            Assert.Equal(viewModel.StartDate, dateTimeNow);
            Assert.Equal(viewModel.EndDate, dateTimeNow.AddMonths(1));
        }
        public void CreateReturnsCorrectDataOnViewModelWhenTimeZoneIdClaimNotSet()
        {
            var dateTimeNow = DateTime.Now;

            var sut = new CampaignController(null, null)
            {
                DateTimeNow = () => dateTimeNow
            };

            sut.SetClaims(new List <Claim>());
            var view      = (ViewResult)sut.Create();
            var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;

            Assert.Equal(viewModel.StartDate, dateTimeNow);
            Assert.Equal(viewModel.EndDate, dateTimeNow.AddMonths(1));
            Assert.Equal(viewModel.TimeZoneId, "UTC");
        }
Exemple #6
0
        public void CampaignDbContextEqualId()
        {
            var options = new DbContextOptionsBuilder <StickerFireDbContext>()
                          .UseInMemoryDatabase(databaseName: "getStatusCode")
                          .Options;

            using (var context = new StickerFireDbContext(options))
            {
                CampaignController c = new CampaignController(userManager, context);


                Campaign campaign = new Campaign();
                campaign.ID      = 1;
                campaign.OwnerID = "1";
                campaign.Title   = "Awesome Sauce Campaign";

                var result = c.Create(campaign, file);


                Assert.Equal(campaign.ID, result.Id);
            }
        }