public async Task ShouldValidateNulls() { var content = new StringContent("[{ id : 1, name: 'Big Fish', director: 'Tim Burton', genre: null, cast: 'Ewan McGregor, Albert Finney, Billy Crudup', duration: null, storyline: 'none', language: 'English', rented: false }]", Encoding.UTF8, "application/json"); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); response.Content = content; var handler = new FakeHttpMessageHandler(response); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); var proxy = new Movies.MoviesApi(client); proxy.SchemaValidation.RaiseExceptions = false; var movies = await proxy.Movies.Get(); Assert.IsTrue(movies.SchemaValidation.Value.IsValid); }
public async Task ShouldNotValidateSchema() { var content = new StringContent("{ name: 'foo' }", Encoding.UTF8, "application/json"); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); response.Content = content; var handler = new FakeHttpMessageHandler(response); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); var proxy = new Movies.MoviesApi(client); proxy.SchemaValidation.RaiseExceptions = false; var movies = await proxy.Movies.Get(); Assert.IsFalse(movies.SchemaValidation.Value.IsValid); }
public async Task ShouldIgnoreNonJsonSchemas() { var content = new StringContent("content", Encoding.UTF8, "text/plain"); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); response.Content = content; var handler = new FakeHttpMessageHandler(response); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); var proxy = new Movies.MoviesApi(client); proxy.SchemaValidation.RaiseExceptions = false; var movies = await proxy.Movies.Get(); Assert.IsTrue(movies.SchemaValidation.Value.IsValid); }
public async Task ShouldNotThrowExceptionForNonJSONSchema() { var content = new StringContent("data", Encoding.UTF8, "text/plain"); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); response.Content = content; var handler = new FakeHttpMessageHandler(response); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); var proxy = new Movies.MoviesApi(client); proxy.SchemaValidation.RaiseExceptions = true; var movies = await proxy.Movies.Get(); Assert.IsNotNull(movies); }
public async Task ShouldThrowExceptionForInvalidSchema() { var content = new StringContent("{ name: 'foo' }", Encoding.UTF8, "application/json"); var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); response.Content = content; var handler = new FakeHttpMessageHandler(response); var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); var proxy = new Movies.MoviesApi(client); proxy.SchemaValidation.RaiseExceptions = true; Assert.Throws<SchemaValidationException>(async () => { var movies = await proxy.Movies.Get(); }); }