Ejemplo n.º 1
0
 public async Task create_a_training()
 {
     var trainingDto = new TrainingDto {
         createdBy   = "1234",
         datetime    = new DateTime(2020, 1, 1),
         description = "ADescription",
         name        = "AName"
     };
     await CreateTraining.Execute(trainingDto).Received();
 }
        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>();
        }