public void When_getting_project_by_campaign_then_result_contains_only_projects_with_given_campaign_ID() { var campaign = new CampaignRepoTests().CreateCampaign(); CreateProject(campaign.Id); var projectsByCampaign = repo.GetByCampaign(campaign.Id); Assert.Contains(projectsByCampaign, item => item.CampaignId == campaign.Id); Assert.DoesNotContain(projectsByCampaign, item => item.CampaignId != campaign.Id); }
public void When_create_campaign_and_and_projects_in_campaign_and_add_some_votes_then_return_back_count_of_projects_and_count_of_project_votes() { var campaign = new CampaignRepoTests().CreateCampaign(); var project1 = CreateProject(campaign.Id); var project2 = CreateProject(campaign.Id); var project3 = CreateProject(campaign.Id); var voteRepo = new VoteRepo(GetDbOptions()); voteRepo.Add(new Vote() { UserId = "ppppffpfp", VotingDateTime = DateTime.Today.AddDays(-5), SocialName = "facebook", ProjectId = project1.Id }); voteRepo.Add(new Vote() { UserId = "ppppfp", VotingDateTime = DateTime.Today.AddDays(-15), SocialName = "facebook", ProjectId = project2.Id }); voteRepo.Add(new Vote() { UserId = "pppd", VotingDateTime = DateTime.Today.AddDays(-3), SocialName = "facebook", ProjectId = project2.Id }); var report = repo.GetProjectsReport(campaign.Id); Assert.Equal(3, report.Count); Assert.Equal(project1.Id, report[0].Project.Id); Assert.Equal(project2.Id, report[1].Project.Id); Assert.Equal(project3.Id, report[2].Project.Id); Assert.Equal(1, report[0].Votes); Assert.Equal(2, report[1].Votes); Assert.Equal(0, report[2].Votes); }