Exemple #1
0
        static IBasketsClient GetBasketsClient(
            string uri,
            params Tuple <string, string>[] headers)
        {
            var httpConn = new HttpConnection(uri, headers);
            var client   = new BasketsClient(httpConn);

            return(client);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello");

            var client = new BasketsClient("http://localhost:50331");
            var result = client.CreateBasketAsync("joe", new CreateBasket {
                BasketId = 1
            }).GetAwaiter().GetResult();

            System.Console.WriteLine($"Result : {string.Join(",", result)}");
            System.Console.ReadKey();
        }
Exemple #3
0
        public async Task GetBasketById_ReturnId_CorrectResults()
        {
            //Arrange
            var basketId    = Guid.NewGuid().ToString();
            var expectedUri = new Uri($"{BaseUri}/{Controller}/{basketId}");
            var expected    = this.fixture.Create <Basket>();

            this.httpConnectionMock
            .Setup(x => x.BaseAddress)
            .Returns(BaseUri);
            this.httpConnectionMock
            .Setup(x => x.GetAsync <Basket>(expectedUri))
            .ReturnsAsync(expected);

            var target = new BasketsClient(this.httpConnectionMock.Object);

            //Act
            var actual = await target.GetBasketAsync(basketId);

            //Assert
            Assert.Equal(expected, actual);
        }