public void return_proper_id_when_create_command_is_called() { var fakeQuery = new FakeTrainingQueries(); var create = new CreateTraining(new EventBus(new EventDispatcher(), new FakeEventStore()), fakeQuery); var training = create.Execute("TEST", 1, Color.Empty.ToArgb()); var firstEvent = training.UncommitedEvents.GetStream().First(); firstEvent.Should().BeAssignableTo <TrainingCreated>(); firstEvent.AggregateId.Should().Be(training.AggregateId); }
public void throw_error_if_training_name_already_exists() { var fakeQuery = new FakeTrainingQueries(); fakeQuery.AddTraining("TEST", 1); var create = new CreateTraining(new EventBus(new EventDispatcher(), new FakeEventStore()), fakeQuery); Action action = () => create.Execute("TEST", 1, Color.Empty.ToArgb()); action.ShouldThrow <TrainingAlreadyExistsException>(); }
public async Task <IActionResult> PostTraining([FromBody] CreateTraining AddTraining) { var training = _mapper.Map <Training> (AddTraining); await _repository.InsertTrainingAsync(training); if (!await _repository.SaveTrainingAsync()) { return(BadRequest($"Unable to create new Traing")); } return(Created("GetTraining", null)); }
public void Setup() { TrainingRepositoryPort = Substitute.For <TrainingRepositoryPostgresSqlAdapter>(); CreateTraining = new CreateTraining(TrainingRepositoryPort); }