public void GetData_Test() { // arrange Products[] products; //Длина массива int expected_length = 5; //Наименования string expected_product_0_ProductName = "Волотовской"; string expected_product_1_ProductName = "Русский"; string expected_product_2_ProductName = "Вкусная"; string expected_product_3_ProductName = "Грузинский"; string expected_product_4_ProductName = "Нарезной"; // act products = ParseString.GetData(GetManufacturingString()); // assert //Длина массива Assert.AreEqual(expected_length, products.Length); //Проверка наименования Assert.AreEqual(expected_product_0_ProductName, products[0].ProductName); Assert.AreEqual(expected_product_1_ProductName, products[1].ProductName); Assert.AreEqual(expected_product_2_ProductName, products[2].ProductName); Assert.AreEqual(expected_product_3_ProductName, products[3].ProductName); Assert.AreEqual(expected_product_4_ProductName, products[4].ProductName); }
public void SortFoodsByPrice_Test() { // arrange Products[] products; Products[] price_foods; double product_0_expected_price = 0.315425; double product_1_expected_price = 0.6376; double product_2_expected_price = 0.7659; double product_3_expected_price = 0.93065; double product_4_expected_price = 1.06313; double delta = 0.001; // act products = ParseString.GetData(GetManufacturingString()); price_foods = new Products[products.Length]; ProductsSort.SortFoodsByPrice(products, ref price_foods); // assert Assert.AreEqual(product_0_expected_price, price_foods[0].Price, delta); Assert.AreEqual(product_1_expected_price, price_foods[1].Price, delta); Assert.AreEqual(product_2_expected_price, price_foods[2].Price, delta); Assert.AreEqual(product_3_expected_price, price_foods[3].Price, delta); Assert.AreEqual(product_4_expected_price, price_foods[4].Price, delta); }
public void SortFoodsByCalorieContent_Test() { // arrange Products[] products; Products[] сalorie_foods; double product_0_expected_сalorie = 646.599; double product_1_expected_сalorie = 859.13; double product_2_expected_сalorie = 1092; double product_3_expected_сalorie = 1556.6; double product_4_expected_сalorie = 1772.6; double delta = 0.001; // act products = ParseString.GetData(GetManufacturingString()); сalorie_foods = new Products[products.Length]; ProductsSort.SortFoodsByCalorieContent(products, ref сalorie_foods); // assert Assert.AreEqual(product_0_expected_сalorie, сalorie_foods[0].Calories, delta); Assert.AreEqual(product_1_expected_сalorie, сalorie_foods[1].Calories, delta); Assert.AreEqual(product_2_expected_сalorie, сalorie_foods[2].Calories, delta); Assert.AreEqual(product_3_expected_сalorie, сalorie_foods[3].Calories, delta); Assert.AreEqual(product_4_expected_сalorie, сalorie_foods[4].Calories, delta); }
public void FindFoodsBigestThenValueIngredient_Test() { // arrange Products[] products; Products[] find_foods_bigest_then_value; string ingredient = "Сахар"; double ingredient_val = 0.005; string expected_product_name = "Нарезной"; // act products = ParseString.GetData(GetManufacturingString()); find_foods_bigest_then_value = new Products[products.Length]; ProductsSort.FindFoodsBigestThenValueIngredient(ingredient, ingredient_val, products, ref find_foods_bigest_then_value); // assert // Должен определиться Нарезной Assert.AreEqual(expected_product_name, find_foods_bigest_then_value[0].ProductName); }
public void FindFoodsByPriceAndByCalorieContent_Test() { // arrange Products[] products; Products[] find_foods_by_price_and_by_calorie; double expected_сalorie = 1092; double expected_price = 0.6376; string expected_product_name = "Грузинский"; double delta = 0.001; // act products = ParseString.GetData(GetManufacturingString()); find_foods_by_price_and_by_calorie = new Products[products.Length]; ProductsSort.FindFoodsByPriceAndByCalorieContent(expected_сalorie, expected_price, products, ref find_foods_by_price_and_by_calorie); // assert Assert.AreEqual(expected_сalorie, find_foods_by_price_and_by_calorie[0].Calories, delta); Assert.AreEqual(expected_price, find_foods_by_price_and_by_calorie[0].Price, delta); // Должен определиться Грузинский Assert.AreEqual(expected_product_name, find_foods_by_price_and_by_calorie[0].ProductName); }
public void FindFoodsNumberIngredientsGreaterThanTheValue_Test() { // arrange Products[] products; Products[] find_foods_number_ingredients_greater_than_the_value; int count = 0; int expected_quantity = 4; // act products = ParseString.GetData(GetManufacturingString()); find_foods_number_ingredients_greater_than_the_value = new Products[products.Length]; ProductsSort.FindFoodsNumberIngredientsGreaterThanTheValue(3, products, find_foods_number_ingredients_greater_than_the_value); foreach (var item in find_foods_number_ingredients_greater_than_the_value) { if (item != null) { count++; } } // assert Assert.AreEqual(expected_quantity, count); }
public void GetPrice_Test() { // arrange Products[] products; //Цена double expected_product_0_price = 0.7659; //убираем дробную часть double expected_product_1_price = 0.9306; double expected_product_2_price = 0.3154; double expected_product_3_price = 0.6376; double expected_product_4_price = 1.0631; double delta = .001; // act products = ParseString.GetData(GetManufacturingString()); // assert //Проверка цены Assert.AreEqual(expected_product_0_price, products[0].Price, delta); Assert.AreEqual(expected_product_1_price, products[1].Price, delta); Assert.AreEqual(expected_product_2_price, products[2].Price, delta); Assert.AreEqual(expected_product_3_price, products[3].Price, delta); Assert.AreEqual(expected_product_4_price, products[4].Price, delta); }
public void GetCalories_Test() { // arrange Products[] products; //Калорийность double expected_product_0_calories = 1556.6; double expected_product_1_calories = 859.13; double expected_product_2_calories = 646.59; double expected_product_3_calories = 1092; double expected_product_4_calories = 1772.6; double delta = 0.01; // act products = ParseString.GetData(GetManufacturingString()); // assert //Проверка калорийности Assert.AreEqual(expected_product_0_calories, products[0].Calories, delta); Assert.AreEqual(expected_product_1_calories, products[1].Calories, delta); Assert.AreEqual(expected_product_2_calories, products[2].Calories, delta); Assert.AreEqual(expected_product_3_calories, products[3].Calories, delta); Assert.AreEqual(expected_product_4_calories, products[4].Calories, delta); }