Exemple #1
0
        public async Task GetReturnsError(HttpStatusCode statusCode, string message, int expectedCode, string expectedMessage)
        {
            var pokemonService = new Mock <IPokemonService>();
            var errorResult    = new ErrorResultContent(statusCode, message);

            pokemonService.Setup(c => c.GetPokemon(_knownName))
            .Returns(Task.FromResult(new Result <ShakespearePokemon>(errorResult)));
            var controller = new PokemonController(pokemonService.Object);

            var result = await controller.Get(_knownName);

            var contentResult = result.Result as ContentResult;

            Assert.AreEqual(expectedCode, contentResult.StatusCode);
            Assert.AreEqual(expectedMessage, contentResult.Content);
        }
Exemple #2
0
 public Error(ErrorResultContent errorResult) : base(errorResult)
 {
 }
Exemple #3
0
 protected Result(ErrorResultContent errorResult)
 {
     ErrorResult = errorResult;
 }
Exemple #4
0
 protected Result()
 {
     ErrorResult = null;
 }