public async Task CompetitionsCount_ShouldReturnCompetitionsCount()
        {
            //Arrange
            var handler = new CompetitionQueryHandler();
            var competitionsFromHandler = await handler.HandleAsync(new CompetitionQuery());

            //Act - do something
            var competitionsFromHandlerCount = competitionsFromHandler.ToList().Count;

            var competitionsFromDatabaseCount = this.context.Competitions.Count();

            //Assert - check results
            Assert.AreEqual(competitionsFromHandlerCount, competitionsFromDatabaseCount);
        }
        public async Task RegisterCompetition_ShouldRegisterCompetition()
        {
            //Arrange
            var handler = new CompetitionQueryHandler();
            var competitionsFromHandler = await handler.HandleAsync(new CompetitionQuery());

            var competitionsFromHandlerCount = competitionsFromHandler.ToList().Count;

            //Act - do something
            CreateCompetitionCommand command = new CreateCompetitionCommand
            {
                Id              = Guid.NewGuid(),
                Description     = "Test description from unit test.",
                CompetitorNames = new List <string>(),
                Name            = "Competition Unit Test",
                EntryFee        = 10
            };

            await createCompetitionHandler.HandleAsync(command);

            var competitionsFromDatabaseCount = this.context.Competitions.Count();

            Assert.AreNotEqual(competitionsFromDatabaseCount, competitionsFromHandlerCount);
        }
Esempio n. 3
0
 public CompetitionController()
 {
     this.handler = new CompetitionQueryHandler();
 }