public async Task CountTest() { var context = EssayCompetitionContextInMemoryFactory.InitializeContext(); await this.SeedData(context); var contestRepository = new EfDeletableEntityRepository <Contest>(context); var essayRepository = new EfDeletableEntityRepository <Essay>(context); var essayTeacherRepository = new EfDeletableEntityRepository <EssayTeacher>(context); var contestantContestRepository = new EfDeletableEntityRepository <ContestantContest>(context); var service = new ContestService(contestRepository, essayRepository, essayTeacherRepository, contestantContestRepository); var countBefore = service.GetContestsCount(); await service.AddContestAsync(DateTime.Now, DateTime.Now, "Legion2", "Legion", context.Categories.First().Id); var countAfter = service.GetContestsCount(); Assert.True(countAfter == countBefore + 1, "Count method does not work correctly"); }
public async Task GetAllTest() { var context = EssayCompetitionContextInMemoryFactory.InitializeContext(); await this.SeedData(context); var contestRepository = new EfDeletableEntityRepository <Contest>(context); var essayRepository = new EfDeletableEntityRepository <Essay>(context); var essayTeacherRepository = new EfDeletableEntityRepository <EssayTeacher>(context); var contestantContestRepository = new EfDeletableEntityRepository <ContestantContest>(context); var service = new ContestService(contestRepository, essayRepository, essayTeacherRepository, contestantContestRepository); var count = service.GetContestsCount(); var allContests = service.GetAllContests <ContestViewModel>(); Assert.True(count == allContests.Count(), "GetAllTest method does not work correctly"); }