예제 #1
0
        public async Task Ok()
        {
            const string name    = "Alex";
            var          command = new CreateCharacterCommand {
                Name = name
            };

            var result = await _handler.Handle(command, CancellationToken.None);

            Assert.NotNull(result);
            Assert.StrictEqual(_addedCharacter, result);
            Assert.Equal(name, result.Name);
            Assert.Null(result.CurrentLocation);
        }
        public async Task Create_character_command_handler_should_return_id_of_created_character()
        {
            // Arrange
            var episode        = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var commandHandler = new CreateCharacterCommandHandler(_testFixture.Context, _testFixture.Mapper);

            // Act
            var response =
                await commandHandler.Handle(new CreateCharacterCommand
                                            { Name = "test char", EpisodesIds = new [] { episode.Id }, FriendsIds = new int[] {} }, CancellationToken.None);

            // Assert
            response.ShouldBeOfType(typeof(int));
        }