public void Should_throw_exception_when_null_client_is_used()
		{
			var fakeRequestCoordinator = A.Fake<IRequestCoordinator>();
			var api = new FluentApi<Status>(fakeRequestCoordinator);

			Assert.Throws<ArgumentNullException>(() => api.UsingClient(null));
		}
		public void SetUp()
		{
			_requestBuilder = A.Fake<IRequestBuilder>();
			var httpClient = A.Fake<IHttpClient>();
			var responseParser = A.Fake<IResponseParser>();

			_fluentApi = new FluentApi<Playlist>(httpClient, _requestBuilder, responseParser);
		}
		public void Should_add_decimal_parameter()
		{
			var basketEndpoint = new FluentApi<AddItemToBasket>(_httpClient, _requestBuilder, _responseParser);
			basketEndpoint.WithParameter("answer", 42.12m);

			Assert.That(basketEndpoint.Parameters.Keys.Contains("answer"));
			Assert.That(basketEndpoint.Parameters["answer"], Is.EqualTo("42.12"));
		}
		public void Should_remove_track_id_parameter_when_adding_a_release_to_basket()
		{
			var basketEndpoint = new FluentApi<AddItemToBasket>();
			basketEndpoint.UseBasketId(Guid.NewGuid()).ForReleaseId(1).ForTrackId(1);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"));
			basketEndpoint.UseBasketId(Guid.NewGuid()).ForReleaseId(1);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"), Is.False);
		}
		public void Should_add_list_parameter_with_multiple_items()
		{
			var basketEndpoint = new FluentApi<AddItemToBasket>(_httpClient, _requestBuilder, _responseParser);
			basketEndpoint.WithParameter("someInts", new[] { 1, 2, 3 });

			Assert.That(basketEndpoint.Parameters.Keys.Contains("someInts"));
			Assert.That(basketEndpoint.Parameters["someInts"], Is.EqualTo("1,2,3"));
		}
        public void TestName()
        {
            var locker = new FluentApi<Locker>(new EndpointResolver(new HttpGetResolver(), new AppSettingsCredentials()))
                .ForUser(TOKEN, TOKEN_SECRET)
                .Please();

            Assert.That(locker.LockerReleases.Count, Is.GreaterThan(0));
        }
		public void Can_retrieve_that_basket()
		{
			Basket basket = new FluentApi<Basket>()
				.WithParameter("basketId", _basketId)
				.Please();

			Assert.That(basket, Is.Not.Null);
			Assert.That(basket.Id, Is.EqualTo(_basketId));
		}
		public void Can_hit_endpoint()
		{
			ArtistSearch artist = new FluentApi<ArtistSearch>()
				.WithParameter("q", "pink")
				.WithParameter("country", "GB")
				.Please();

			Assert.That(artist, Is.Not.Null);			
		}
		public void Should_remove_track_and_release_parameters_when_getting_a_basket()
		{
			var basketEndpoint = new FluentApi<Basket>();
			basketEndpoint.AddItem(Guid.NewGuid(), 1, 1);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"));
			basketEndpoint.GetBasket(Guid.NewGuid());
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"), Is.False);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("releaseId"), Is.False);
		}
		public void Can_hit_endpoint()
		{
			ArtistTopTracks artist = new FluentApi<ArtistTopTracks>()
				.WithParameter("artistId", "1")
				.WithParameter("country", "GB")
				.Please();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Tracks.Count, Is.GreaterThan(0));
		}
예제 #11
0
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver()); 

			Status status = new FluentApi<Status>(httpGetResolver)
								.Resolve();

			Assert.That(status, Is.Not.Null);
			Assert.That(status.ServerTime.Day, Is.EqualTo(DateTime.Now.Day));
		}
		public void Can_create_basket()
		{
			Basket basketCreate = new FluentApi<Basket>()
				.WithEndpoint("basket/create")
				.WithParameter("country", "GB")
				.Please();

			Assert.That(basketCreate, Is.Not.Null);
			Assert.That(basketCreate.Id, Is.Not.Empty);
			_basketId = basketCreate.Id;
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ArtistBrowse artistBrowse = new FluentApi<ArtistBrowse>(httpGetResolver).WithParameter("letter", "radio").Resolve();

			Assert.That(artistBrowse, Is.Not.Null);
			Assert.That(artistBrowse.Page, Is.EqualTo(1));
			Assert.That(artistBrowse.PageSize, Is.EqualTo(10));
			Assert.That(artistBrowse.Artists.Count,Is.GreaterThan(0));
		}
		public void Can_get_multiple_results_with_new_FluentApi_overload() {
			var artistSearch = new FluentApi<ArtistSearch>(new AppSettingsCredentials(), new ApiUri())
									.ForShop(34)
									.WithQuery("pink")
									.WithPageNumber(1)
									.WithPageSize(20)
									.Please();

			Assert.That(artistSearch.Results.Count, Is.GreaterThan(1));

		}
		public void Can_hit_endpoint()
		{
			ArtistReleases artist = new FluentApi<ArtistReleases>()
				.WithParameter("artistId", "1")
				.WithParameter("country", "GB")
				.Please();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Releases.Count, Is.GreaterThan(0));
			Assert.That(artist.Releases.FirstOrDefault().Artist.Name, Is.EqualTo("Keane"));
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());
			Track track = new FluentApi<Track>(httpGetResolver)
				.WithTrackId(12345)
				.Resolve();

			Assert.That(track, Is.Not.Null);
			Assert.That(track.Title, Is.EqualTo("I Love You"));
			Assert.That(track.Artist.Name, Is.EqualTo("The Dandy Warhols"));
		}
		public void Can_hit_endpoint_with_paging()
		{
			ArtistReleases artistBrowse = new FluentApi<ArtistReleases>()
				.WithParameter("artistId", "1")
				.WithParameter("page", "2")
				.WithParameter("pageSize", "20")
				.Please();

			Assert.That(artistBrowse, Is.Not.Null);
			Assert.That(artistBrowse.Page, Is.EqualTo(2));
			Assert.That(artistBrowse.PageSize, Is.EqualTo(20));
		}
		public void Can_hit_endpoint_with_paging()
		{
			ArtistTopTracks artist = new FluentApi<ArtistTopTracks>()
				.WithParameter("artistId", "1")
				.WithParameter("page", "2")
				.WithParameter("pageSize", "10")
				.Please();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Page, Is.EqualTo(2));
			Assert.That(artist.PageSize, Is.EqualTo(10));
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ArtistTopTracks artist = new FluentApi<ArtistTopTracks>(httpGetResolver)
				.WithParameter("artistId", "1")
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Tracks.Count, Is.GreaterThan(0));
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ReleaseRecommend release = new FluentApi<ReleaseRecommend>(httpGetResolver)
				.WithParameter("releaseId", "155408")
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(release, Is.Not.Null);
			Assert.That(release.RecommendedItems.Count, Is.GreaterThan(0));
		}
		public void SetUp()
		{
			_requestBuilder = A.Fake<IRequestBuilder>();
			var httpClient = A.Fake<IHttpClient>();
			var responseParser = A.Fake<IResponseParser>();

			var responseXml = File.ReadAllText("StubResponses/Playlists.xml");
			var validPlaylistsResponse = new Response(HttpStatusCode.OK, responseXml);
			A.CallTo(() => httpClient.Send(null)).WithAnyArguments().Returns(Task.FromResult(validPlaylistsResponse));
			_fluentApi = new FluentApi<UserPlaylists>(httpClient, _requestBuilder, responseParser);

		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ArtistSearch artist = new FluentApi<ArtistSearch>(httpGetResolver)
				.WithParameter("q", "pink")
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Results.Artists.Count, Is.GreaterThan(0));
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			Release release = new FluentApi<Release>(httpGetResolver)
				.WithParameter("releaseId", "155408")
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(release, Is.Not.Null);
			Assert.That(release.Title, Is.EqualTo("Dreams"));
			Assert.That(release.Artist.Name, Is.EqualTo("The Whitest Boy Alive"));
		}
		public async void SetUp()
		{
			var requestBuilder = A.Fake<IRequestBuilder>();
			var httpClient = A.Fake<IHttpClient>();
			var responseParser = new ResponseParser(new ApiResponseDetector());

			var responseXml = File.ReadAllText("StubResponses/Playlist.xml");
			var validPlaylistsResponse = new Response(HttpStatusCode.OK, responseXml);
			A.CallTo(() => httpClient.Send(null)).WithAnyArguments().Returns(Task.FromResult(validPlaylistsResponse));
			var fluentApi = new FluentApi<Playlist>(httpClient, requestBuilder, responseParser);

			_playlist = await fluentApi.Please();
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ReleaseByDate release = new FluentApi<ReleaseByDate>(httpGetResolver)
				.WithParameter("fromDate", "20110101")
				.WithParameter("toDate", "20110301")
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(release, Is.Not.Null);
			Assert.That(release.Releases.Count, Is.GreaterThan(0));
		}
		public void Should_not_remove_track_id_parameter_when_adding_a_release_to_basket()
		{
			var requestBuilder = A.Fake<IRequestBuilder>();
			var responseParser = A.Fake<IResponseParser>();
			var httpClient = A.Fake<IHttpClient>();

			var basketEndpoint = new FluentApi<AddItemToBasket>(httpClient, requestBuilder, responseParser);
			basketEndpoint.UseBasketId(NewBasketId()).ForReleaseId(1).ForTrackId(1);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"));

			basketEndpoint.UseBasketId(NewBasketId());
			Assert.That(basketEndpoint.Parameters.Keys.Contains("releaseId"), Is.True);
			Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"), Is.True);
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver()); // TODO: Set up using castle?

			Artist artist = new FluentApi<Artist>(httpGetResolver)
				.WithParameter("artistid","1")
				.Resolve();
			
			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Name, Is.EqualTo("Keane"));
			Assert.That(artist.SortName, Is.EqualTo("Keane"));
			Assert.That(artist.Url, Is.EqualTo("http://www.7digital.com/artists/keane/?partner=1401"));
			Assert.That(artist.Image, Is.EqualTo("http://cdn.7static.com/static/img/artistimages/00/000/000/0000000001_150.jpg"));
		}
		public void Can_hit_endpoint_with_paging()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ArtistSearch artistBrowse = new FluentApi<ArtistSearch>(httpGetResolver)
				.WithParameter("q", "pink")
				.WithParameter("page", "2")
				.WithParameter("pageSize", "20")
				.Resolve();

			Assert.That(artistBrowse, Is.Not.Null);
			Assert.That(artistBrowse.Page, Is.EqualTo(2));
			Assert.That(artistBrowse.PageSize, Is.EqualTo(20));
		}
		public void Can_hit_endpoint_with_paging()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ArtistTopTracks artist = new FluentApi<ArtistTopTracks>(httpGetResolver)
				.WithParameter("artistId", "1")
				.WithParameter("page", "2")
				.WithParameter("pageSize", "10")
				.Resolve();

			Assert.That(artist, Is.Not.Null);
			Assert.That(artist.Page, Is.EqualTo(2));
			Assert.That(artist.PageSize, Is.EqualTo(10));
		}
		public void Can_hit_endpoint()
		{
			var httpGetResolver = new EndpointResolver(new HttpGetResolver());

			ReleaseSearch release = new FluentApi<ReleaseSearch>(httpGetResolver)
				.WithParameter("q", "no surprises")
				.WithParameter("type", ReleaseType.Video.ToString())
				.WithParameter("country", "GB")
				.Resolve();

			Assert.That(release, Is.Not.Null);
			Assert.That(release.Results.Releases.Count, Is.GreaterThan(0));
			Assert.That(release.Results.Releases.FirstOrDefault().Type, Is.EqualTo(ReleaseType.Video));
		}
예제 #31
0
            public void CanInterpretRuleWithAndOperator()
            {
                // Prepare
                FluentApi.Property(vm => vm.Quantity).IsNot.EqualTo(10).And.Is.EqualTo(20);

                // Act
                var expressionBase = Parser.Parse(Tokens);
                var taskResult     = expressionBase.Evaluate(new CancellationToken());

                taskResult.Start();

                // Verify
                Assert.IsInstanceOfType(expressionBase, typeof(AndExpression));
                Assert.IsTrue(taskResult.Result);
            }
        public void Should_not_remove_track_id_parameter_when_adding_a_release_to_basket()
        {
            var requestBuilder = A.Fake <IRequestBuilder>();
            var responseParser = A.Fake <IResponseParser>();
            var httpClient     = A.Fake <IHttpClient>();

            var basketEndpoint = new FluentApi <AddItemToBasket>(httpClient, requestBuilder, responseParser);

            basketEndpoint.UseBasketId(NewBasketId()).ForReleaseId(1).ForTrackId(1);
            Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"));

            basketEndpoint.UseBasketId(NewBasketId());
            Assert.That(basketEndpoint.Parameters.Keys.Contains("releaseId"), Is.True);
            Assert.That(basketEndpoint.Parameters.Keys.Contains("trackId"), Is.True);
        }
예제 #33
0
            public void CanInterpretUsingOperatorPrecedence()
            {
                // Prepare
                FluentApi.Property(vm => vm.Quantity).Is.EqualTo(5).Or.IsNot.EqualTo(5).And.Is.EqualTo(6);

                // Act
                var expressionBase = Parser.Parse(Tokens);
                var taskResult     = expressionBase.Evaluate(new CancellationToken());

                taskResult.Start();

                // Verify
                Assert.IsInstanceOfType(expressionBase, typeof(OrExpression));
                Assert.IsFalse(taskResult.Result);
            }
예제 #34
0
        public void TestInitialize()
        {
            string conn = "user id=CLINIC;password=CLINIC;data source=192.168.0.91/orcl";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.Oracle, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);
            service        = new AppService(freeSqlContext);
            fsq.Delete <App>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
예제 #35
0
        public void TestInitialize()
        {
            string conn = "Persist Security Info = False; User ID =dev; Password =dev@123,; Initial Catalog =agile_config_test; Server =xxxxx";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.SqlServer, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);
            service        = new AppService(freeSqlContext);
            fsq.Delete <App>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
예제 #36
0
            public void CanInterpretSimpleRule()
            {
                // Prepare
                FluentApi.Property(vm => vm.Quantity).Is.EqualTo(10);

                // Act
                var expressionBase = Parser.Parse(Tokens);
                var taskResult     = expressionBase.Evaluate(new CancellationToken());

                taskResult.Start();

                // Verify
                Assert.IsInstanceOfType(expressionBase, typeof(EqualToExpression));
                Assert.IsFalse(taskResult.Result);
            }
예제 #37
0
        public async void Should_use_custom_http_client()
        {
            var requestHandler = StubRequestBuilder();
            var httpClient     = StubHttpClient();
            var responseParser = StubResponseParser();
            var fakeHttpClient = new FakeHttpClient(_stubResponse);

            var api = new FluentApi <Status>(httpClient, requestHandler, responseParser).UsingClient(fakeHttpClient);

            Assert.That(fakeHttpClient.SendCount, Is.EqualTo(0));

            await api.Please();

            Assert.That(fakeHttpClient.SendCount, Is.EqualTo(1));
        }
예제 #38
0
        public void TestInitialize()
        {
            string conn = "Host=127.0.0.1;Database=agile_config;Username=postgres;Password=dev@123";

            fsq = new FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.PostgreSQL, conn)
                  .UseAutoSyncStructure(true)
                  .Build();
            FluentApi.Config(fsq);
            freeSqlContext = new FreeSqlContext(fsq);
            service        = new AppService(freeSqlContext);
            fsq.Delete <App>().Where("1=1");

            Console.WriteLine("TestInitialize");
        }
예제 #39
0
        public async void Should_not_hit_endpoint_when_value_is_found_in_cache()
        {
            var requestHandler = StubRequestBuilder();
            var httpClient     = StubHttpClient();
            var responseParser = StubResponseParser();

            var api = new FluentApi <Status>(httpClient, requestHandler, responseParser);

            var cache = new FakeCache();

            cache.StubCachedObject = _stubStatus;

            await api.UsingCache(cache).Please();

            A.CallTo(() => httpClient.Send(A <Request> .Ignored)).MustNotHaveHappened();
        }
예제 #40
0
        public void ExistTableOracleTest()
        {
            //SqlServer
            string conn       = "user id=CLINIC;password=CLINIC;data source=192.168.0.91/orcl";
            var    oracle_fsq = new FreeSqlBuilder()
                                .UseConnectionString(FreeSql.DataType.Oracle, conn)
                                .Build();

            FluentApi.Config(oracle_fsq);
            oracle_fsq.Ado.ExecuteNonQuery("drop table \"app\" ");
            var ex = EnsureTables.ExistTable(oracle_fsq);

            Assert.IsFalse(ex);
            oracle_fsq.CodeFirst.SyncStructure <App>();
            ex = EnsureTables.ExistTable(oracle_fsq);
            Assert.IsTrue(ex);
        }
예제 #41
0
        public void ExistTableMysqlTest()
        {
            //SqlServer
            string conn      = "Database=agile_config_test;Data Source=localhost;User Id=root;Password=dev@123;port=3306";
            var    mysql_fsq = new FreeSqlBuilder()
                               .UseConnectionString(FreeSql.DataType.MySql, conn)
                               .Build();

            FluentApi.Config(mysql_fsq);
            mysql_fsq.Ado.ExecuteNonQuery("drop table app");
            var ex = EnsureTables.ExistTable(mysql_fsq);

            Assert.IsFalse(ex);
            mysql_fsq.CodeFirst.SyncStructure <App>();
            ex = EnsureTables.ExistTable(mysql_fsq);
            Assert.IsTrue(ex);
        }
예제 #42
0
        public void ExistTableSqlServerTest()
        {
            //SqlServer
            string conn          = "Persist Security Info = False; User ID =dev; Password =,; Initial Catalog =agile_config_test; Server =xxxx";
            var    sqlserver_fsq = new FreeSqlBuilder()
                                   .UseConnectionString(FreeSql.DataType.SqlServer, conn)
                                   .Build();

            FluentApi.Config(sqlserver_fsq);
            sqlserver_fsq.Ado.ExecuteNonQuery("drop table app");
            var ex = EnsureTables.ExistTable(sqlserver_fsq);

            Assert.IsFalse(ex);
            sqlserver_fsq.CodeFirst.SyncStructure <App>();
            ex = EnsureTables.ExistTable(sqlserver_fsq);
            Assert.IsTrue(ex);
        }
예제 #43
0
        public void ExistTableSqliteTest()
        {
            //sqlite
            string conn        = "Data Source=agile_config.db";
            var    sqllite_fsq = new FreeSqlBuilder()
                                 .UseConnectionString(FreeSql.DataType.Sqlite, conn)
                                 .Build();

            FluentApi.Config(sqllite_fsq);
            sqllite_fsq.Ado.ExecuteNonQuery("drop table app");
            var ex = EnsureTables.ExistTable(sqllite_fsq);

            Assert.IsFalse(ex);
            sqllite_fsq.CodeFirst.SyncStructure <App>();
            ex = EnsureTables.ExistTable(sqllite_fsq);
            Assert.IsTrue(ex);
        }
        public void Can_hit_endpoint()
        {
            var httpGetResolver = new EndpointResolver(new HttpGetResolver(), new AppSettingsCredentials());

            ArtistChart artist = new FluentApi <ArtistChart>(httpGetResolver)
                                 .WithParameter("period", "week")
                                 .WithParameter("toDate", "20110131")
                                 .WithParameter("country", "GB")
                                 .Please();

            Assert.That(artist, Is.Not.Null);
            Assert.That(artist.ChartItems.Count, Is.EqualTo(10));
            Assert.That(artist.Type, Is.EqualTo(ChartType.artist));
            Assert.That(artist.FromDate, Is.EqualTo(new DateTime(2011, 01, 25)));
            Assert.That(artist.ToDate, Is.EqualTo(new DateTime(2011, 01, 31)));
            Assert.That(artist.ChartItems.FirstOrDefault().Artist, Is.Not.Null);
        }
예제 #45
0
        public void ExistTablePostgreSqlTest()
        {
            //SqlServer
            string conn           = "Host=127.0.0.1;Database=agile_config;Username=postgres;Password=dev@123";
            var    postgresql_fsq = new FreeSqlBuilder()
                                    .UseConnectionString(FreeSql.DataType.PostgreSQL, conn)
                                    .Build();

            FluentApi.Config(postgresql_fsq);
            postgresql_fsq.Ado.ExecuteNonQuery("drop table \"app\" ");
            var ex = EnsureTables.ExistTable(postgresql_fsq);

            Assert.IsFalse(ex);
            postgresql_fsq.CodeFirst.SyncStructure <App>();
            ex = EnsureTables.ExistTable(postgresql_fsq);
            Assert.IsTrue(ex);
        }
예제 #46
0
        public void Should_wrap_webexception_under_api_exception_to_know_the_URL()
        {
            const string url = "http://example.com/status";

            var requestHandler = StubRequestBuilder();
            var httpClient     = StubHttpClient();

            A.CallTo(() => httpClient.Send(A <Request> .Ignored)).Throws <WebException>();

            var api = new FluentApi <Status>(httpClient, requestHandler);

            var ex = Assert.Throws <ApiWebException>(async() => await api.Please());

            Assert.That(ex.InnerException, Is.Not.Null);
            Assert.That(ex.OriginalRequest.Url, Is.EqualTo(url));
            Assert.That(ex.InnerException.GetType(), Is.EqualTo(typeof(WebException)));
        }
예제 #47
0
        public void Should_not_write_to_cache_on_failure()
        {
            var requestHandler = StubRequestBuilder();
            var httpClient     = StubHttpClient();
            var api            = new FluentApi <Status>(httpClient, requestHandler);

            var cache = new FakeCache();

            A.CallTo(() => httpClient.Send(A <Request> .Ignored)).Throws <WebException>();

            api.UsingCache(cache);

            Assert.Throws <ApiWebException>(async() => await api.Please());

            Assert.That(cache.SetCount, Is.EqualTo(0));
            Assert.That(cache.CachedResponses.Count, Is.EqualTo(0));
        }
        public void Can_add_and_remove_track_to_that_that_basket()
        {
            Basket basket = new FluentApi <Basket>()
                            .WithEndpoint("basket/additem")
                            .WithParameter("basketId", _basketId)
                            .WithParameter("releaseId", EXPECTED_RELEASE_ID)
                            .WithParameter("trackId", EXPECTED_TRACK_ID)
                            .Please();

            Assert.That(basket, Is.Not.Null); Assert.That(basket.Id, Is.EqualTo(_basketId));
            Assert.That(basket.BasketItems.Items.Count, Is.GreaterThan(0));
            Assert.That(basket.BasketItems.Items.FirstOrDefault().TrackId, Is.EqualTo(EXPECTED_TRACK_ID));

            int toRemove = basket.BasketItems.Items.FirstOrDefault().Id;

            basket = new FluentApi <Basket>()
                     .WithEndpoint("basket/removeitem")
                     .WithParameter("basketid", _basketId)
                     .WithParameter("itemid", toRemove.ToString())
                     .Please();
            Assert.That(basket, Is.Not.Null);
            Assert.That(basket.Id, Is.EqualTo(_basketId));
            Assert.That(basket.BasketItems.Items.Where(x => x.Id == toRemove).Count(), Is.EqualTo(0));
        }
 public void SetUp()
 {
     _fluentApi = new FluentApi <ArtistTopTracks>(new HttpClientMediator(), new RequestBuilder(new ApiUri(), new AppSettingsCredentials()), new ResponseParser(new ApiResponseDetector()));
 }