Exemplo n.º 1
0
        async Task Run()
        {
            var client = new BasketClient("https://localhost:5001");
            var userId = Guid.NewGuid();
            var basket = await client.Create(userId);

            await client.SetItem(basket.Id, Guid.NewGuid(), 2);

            await client.SetItem(basket.Id, Guid.NewGuid(), 3);

            basket = await client.Get(basket.Id);

            WriteBasket(basket);

            await client.RemoveItem(basket.Id, basket.Items.ToArray()[0].ProductId);

            basket = await client.Get(basket.Id);

            WriteBasket(basket);

            await client.Clear(basket.Id);

            basket = await client.Get(basket.Id);

            WriteBasket(basket);
        }
Exemplo n.º 2
0
        public void Clearbasket_ClearsBasket()
        {
            var expectedRequest = new RestRequest()
            {
                Method = Method.POST
            };
            var dummySettings = new BasketClientSettings()
            {
                BaseUrl = "https://api.co.uk"
            };
            var restClientMock         = new Mock <IRestClient>();
            var restRequestFactoryMock = new Mock <IRestRequestBuilder>();

            restRequestFactoryMock.Setup(x => x.Build()).Returns(expectedRequest);
            var sut = new BasketClient(dummySettings, restClientMock.Object, restRequestFactoryMock.Object);

            sut.Clear();

            restClientMock.Verify(x => x.Execute(expectedRequest));
        }