コード例 #1
0
        public CreateTrainingCommandTest()
        {
            var cache = new Mock <IDistributedCache>();

            _context        = InitAndGetDbContext(out _tenantId, out _adminUserId, out _trainingSeriesId, out _trainingCategoryId);
            _commandHandler = new CreateTrainingCommandHandler(_context, new CacheManager(cache.Object));
        }
コード例 #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());
        }