示例#1
0
        private void AddDrink()
        {
            var   elements = ReadElements();
            Drink drink    = new Drink(elements[0], elements[1], decimal.Parse(elements[2]), int.Parse(elements[3]));

            drinkController.Add(drink);
            Console.WriteLine("The product was successfully added!");
        }
示例#2
0
        public void AddDrink_Add_A_Drink()
        {
            var mockSet     = new Mock <DbSet <Drink> >();
            var drink       = new Drink();
            var mockContext = new Mock <ShopContext>();

            mockContext.Setup(m => m.Drinks).Returns(mockSet.Object);

            var controller = new DrinkController(mockContext.Object);

            controller.Add(drink);

            mockSet.Verify(m => m.Add(It.IsAny <Drink>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
示例#3
0
        public void Add_DrinkNameAndQuantity_DrinkAdded()
        {
            // Arrange
            var added = false;
            var drink = new DrinkDTO {
                Name = "DrinkName", Quantity = 1
            };

            _drinkServiceMock.Setup(
                s =>
                s.AddDrink(drink)).Callback(() => added = true);

            // Act
            _controller.Add(drink);

            // Assert
            Assert.IsTrue(added);
        }
示例#4
0
        public void ドリンクを指定本数格納できるかテスト(int num)
        {
            var target = new DrinkController();

            //ドリンクを追加
            var cola = this.SetDorink(120, "コーラ");

            for (var i = 0; i < num; i++)
            {
                target.Add(cola);
            }


            //5本格納しているか
            var expectNum = num;
            var actualNum = target.Count();

            Assert.AreEqual(expectNum, actualNum);
        }
示例#5
0
 private void button12_Click(object sender, EventArgs e)
 {
     if (SectionNumber == 1)
     {
         Pastry pastry = new Pastry();
         pastry.Category = textBox1.Text;
         pastry.Name     = textBox2.Text;
         pastry.Price    = decimal.Parse(textBox3.Text);
         pastry.Quantity = int.Parse(textBox4.Text);
         pastryController.Add(pastry);
     }
     if (SectionNumber == 2)
     {
         FruitsAndVegetable fruitsAndVegetable = new FruitsAndVegetable();
         fruitsAndVegetable.Category = textBox1.Text;
         fruitsAndVegetable.Name     = textBox2.Text;
         fruitsAndVegetable.Price    = decimal.Parse(textBox3.Text);
         fruitsAndVegetable.Quantity = int.Parse(textBox4.Text);
         fruitAndVegetableController.Add(fruitsAndVegetable);
     }
     if (SectionNumber == 3)
     {
         Nut nut = new Nut();
         nut.Category = textBox1.Text;
         nut.Name     = textBox2.Text;
         nut.Price    = decimal.Parse(textBox3.Text);
         nut.Quantity = int.Parse(textBox4.Text);
         nutController.Add(nut);
     }
     if (SectionNumber == 4)
     {
         Drink drink = new Drink();
         drink.Category = textBox1.Text;
         drink.Name     = textBox2.Text;
         drink.Price    = decimal.Parse(textBox3.Text);
         drink.Quantity = int.Parse(textBox4.Text);
         drinkController.Add(drink);
     }
     MessageBox.Show("The product was successfully added!");
 }
示例#6
0
        public void 格納したドリンクが全て指定銘柄かテスト(string name)
        {
            var target = new DrinkController();


            //ドリンクを追加
            var cola = this.SetDorink(120, name);

            for (var i = 0; i < 5; i++)
            {
                target.Add(cola);
            }

            var expected = name;

            var allList = target.AllList();

            foreach (var n in allList)
            {
                var actual = n.Name();
                Assert.AreEqual(expected, actual);
            }
        }
示例#7
0
        public void 格納したドリンクが全て指定金額かテスト(int price)
        {
            var target = new DrinkController();


            //ドリンクを追加
            var cola = this.SetDorink(price, "コーラ");

            for (var i = 0; i < 5; i++)
            {
                target.Add(cola);
            }

            var expected = price;

            var allList = target.AllList();

            foreach (var n in allList)
            {
                var actual = n.Price();
                Assert.AreEqual(expected, actual);
            }
        }