Exemplo n.º 1
0
        public async Task Test_Get_Menu()
        {
            /*
             * API'yi test etmek için TestClientProvider class'ı ekledim,
             * ve buradan gelen client ile testleri yapıyorum.
             */
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/api/menu/get");

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Exemplo n.º 2
0
        public async Task Test_Get_OrderList()
        {
            /*
             * API'yi test etmek için TestClientProvider class'ı ekledim,
             * ve buradan gelen client ile testleri yapıyorum.
             * StatusCode'lar için ise FluentAssetions NuGet paketini kullandım.
             */
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/api/orders/list");

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Exemplo n.º 3
0
        public async Task Test_AddNewAddition_ToMenu()
        {
            using (var client = new TestClientProvider().Client)
            {
                /*we have 3 items default, we are adding one more item to menu.
                 * We expect to have returned 4 items in total.
                 */
                var response = await client.GetAsync("/api/menu/add/addition?_Id=4&_Name=Sugar");

                response.EnsureSuccessStatusCode();
                var stringResponse = await response.Content.ReadAsStringAsync();

                var terms = JsonConvert.DeserializeObject <Menu>(stringResponse);
                Assert.True(terms.Additions.Count > 3);
            }
        }
Exemplo n.º 4
0
        public async Task Test_NewOrderItem_WithMultiAddition()
        {
            using (var client = new TestClientProvider().Client)
            {
                //1 beverage 2 milk additions
                var response = await client.GetAsync("/api/orders/add?beverageId=1&additionIds=1&additionIds=1");

                response.EnsureSuccessStatusCode();
                var stringResponse = await response.Content.ReadAsStringAsync();

                var terms         = JsonConvert.DeserializeObject <OrderList>(stringResponse);
                var returnedItems = terms.items;
                Assert.Single(returnedItems);
                Assert.Contains(returnedItems, x => x.addition.Count > 1);
                Assert.Contains(returnedItems, x => x.beverage != null);
            }
        }