示例#1
0
        public async Task <IActionResult> Competition([FromBody] CreateCompetitionCommand command)
        {
            var handler = new CreateCompetitionHandler();
            await handler.HandleAsync(command);

            return(this.Created(StaticConstants.Empty, new { message = StaticConstants.CompetitionCreatedSuccessMessage }));
        }
        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);
        }
示例#3
0
 public async Task <ActionResult <int> > Create(CreateCompetitionCommand command)
 {
     return(await Mediator.Send(command));
 }