Esempio n. 1
0
        public void Test_Topping_Price(decimal expected, int testID)
        {
            var context = new PizzaBoxContext();
            // arrange
            Atopping sut = context.Atoppings.Where(t => t.Id == testID).FirstOrDefault();

            // act
            var actual = sut.ToppingPrice;

            // assert
            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        public void CheeseToppingTest()
        {
            var context = new PizzaBoxContext();
            // arrange
            Atopping sut      = context.Atoppings.Where(t => t.Id == 1).FirstOrDefault();
            var      expected = "Cheese";

            // act
            var actual = sut.ToppingName;

            // assert
            Assert.Equal(expected, actual);
        }
        /*
         *  This will check the database for any item that isn't part of anything that generates
         *  and will give it default values
         */
        static void checkDatabase()
        {
            var context = new PizzaBoxContext();

            if (!context.Astores.Any())
            {
                var top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Freddys Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
                top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Chicago Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
            }
            if (!context.Atoppings.Any())
            {
                var top = new Atopping()
                {
                    ToppingName  = "Cheese",
                    ToppingPrice = 0m,
                    Id           = 1
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
                top = new Atopping()
                {
                    ToppingName  = "Peporoni",
                    ToppingPrice = 0.5m,
                    Id           = 2
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
            }
            if (!context.Acrusts.Any())
            {
                var top = new Acrust()
                {
                    CrustName  = "Thin",
                    CrustPrice = 0m,
                    Id         = 1
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Regular",
                    CrustPrice = 0m,
                    Id         = 2
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Deep Dish",
                    CrustPrice = 1m,
                    Id         = 3
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Stuff Crust",
                    CrustPrice = 2m,
                    Id         = 4
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
            }
            if (!context.Asizes.Any())
            {
                var top = new Asize()
                {
                    SizeName  = "Small",
                    SizePrice = 0m,
                    Id        = 1
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Medium",
                    SizePrice = 1m,
                    Id        = 2
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Large",
                    SizePrice = 2m,
                    Id        = 3
                };
                context.Asizes.Add(top);
                context.SaveChanges();
            }
            if (!context.Apizzas.Any())
            {
                var top = new Apizza()
                {
                    Id        = 1,
                    PizzaName = "Cheese Pizza",
                    Topping1  = 1,
                    Topping2  = 1,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 10.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
                top = new Apizza()
                {
                    Id        = 2,
                    PizzaName = "Peporoni",
                    Topping1  = 1,
                    Topping2  = 2,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 12.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
            }
        }