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)); }
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()); }