public async void EnsureAsyncGetTopProductsReturnsItems()
 {
     // Only test happy path, as the MusicClient tests cover the unhappy path
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     ListResponse<Product> result = await client.GetTopProductsAsync(Category.Album);
     Assert.Greater(result.Result.Count, 0, "Expected more than 0 results");
 }
Esempio n. 2
0
 public async Task EnsureGetTopProductsReturnsErrorForFailedCall()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
     ListResponse<Product> result = await client.GetTopProductsAsync(Category.Album);
     Assert.IsNotNull(result, "Expected a result");
     Assert.IsNotNull(result.StatusCode, "Expected a status code");
     Assert.IsTrue(result.StatusCode.HasValue, "Expected a status code");
     Assert.AreNotEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a non-OK response");
     Assert.IsNotNull(result.Error, "Expected an error");
     Assert.AreEqual(typeof(ApiCallFailedException), result.Error.GetType(), "Expected an ApiCallFailedException");
 }
Esempio n. 3
0
        public async Task EnsureGetTopProductsReturnsErrorForFailedCall()
        {
            IMusicClient           client = new MusicClient("test", "gb", new MockApiRequestHandler(FakeResponse.NotFound()));
            ListResponse <Product> result = await client.GetTopProductsAsync(Category.Album);

            Assert.IsNotNull(result, "Expected a result");
            Assert.IsNotNull(result.StatusCode, "Expected a status code");
            Assert.IsTrue(result.StatusCode.HasValue, "Expected a status code");
            Assert.AreNotEqual(HttpStatusCode.OK, result.StatusCode.Value, "Expected a non-OK response");
            Assert.IsNotNull(result.Error, "Expected an error");
            Assert.AreEqual(typeof(ApiCallFailedException), result.Error.GetType(), "Expected an ApiCallFailedException");
        }
Esempio n. 4
0
 public async Task EnsureGetTopProductsReturnsItems()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     this.ValidateTopProductsResponse(await client.GetTopProductsAsync(Category.Album));
 }
Esempio n. 5
0
 public async Task EnsureGetTopProductsThrowsExceptionForUnsupportedCategory()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     await client.GetTopProductsAsync(Category.Unknown);
 }
Esempio n. 6
0
        public async Task EnsureGetTopProductsReturnsItems()
        {
            IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));

            this.ValidateTopProductsResponse(await client.GetTopProductsAsync(Category.Album));
        }
Esempio n. 7
0
 public async Task EnsureGetTopProductsThrowsExceptionForUnsupportedCategory()
 {
     IMusicClient client = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.product_parse_tests));
     await client.GetTopProductsAsync(Category.Unknown);
 }