Ejemplo n.º 1
0
        public async Task ShouldGetModelForValidInformation()
        {
            var command = new CreateTrainingCommand
            {
                CreatedBy            = _adminUserId,
                TenantId             = _tenantId,
                CreateTrainingModels = new List <CreateTrainingCommandModel>
                {
                    new CreateTrainingCommandModel
                    {
                        TrainingSeriesId   = _trainingSeriesId,
                        TrainingCategoryId = _trainingCategoryId,
                        Name          = "trainingSample",
                        Description   = "sampleDescription",
                        EndDateTime   = DateTimeOffset.Now.AddDays(5),
                        BeginDateTime = DateTimeOffset.Now
                    }
                }
            };

            var trainingResponseModel = await _commandHandler.Handle(command, CancellationToken.None);

            Assert.Null(trainingResponseModel.Errors);

            Assert.True(trainingResponseModel.Items.Single().Count > 0);
        }
Ejemplo n.º 2
0
        public async Task Handler_SuccessfullyPersistsTraining()
        {
            var command = new CreateTrainingCommand
            {
                Description = "Learning to do stuff",
                Location    = "The learning place",
                Start       = DateTime.Now,
                End         = DateTime.Now.AddHours(5)
            };
            var handler = new CreateTrainingCommandHandler(mockRepo.Object);

            await handler.Handle(command, CancellationToken.None);

            mockRepo.Verify(x => x.Add(It.Is <Training>(
                                           t => t.Description == command.Description &&
                                           t.Location == command.Location &&
                                           t.TrainingPeriod.Start == command.Start &&
                                           t.TrainingPeriod.End == command.End
                                           )), Times.Once());
        }