Beispiel #1
0
        public static MockDbContext GetDbContext(bool withData = true)
        {
            var options = new DbContextOptionsBuilder().UseInMemoryDatabase("dbtest").Options;
            var db      = new MockDbContext(options);

            if (withData)
            {
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 1", Price = 10, Topping = "Champignon"
                });
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 2", Price = 11, Topping = "Champignon"
                });
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 3", Price = 12, Topping = "Champignon"
                });
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0123455678", Lastname = "Test1"
                });
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0123455679", Lastname = "Test2"
                });
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0123455670", Lastname = "Test3"
                });

                db.SaveChanges();
            }

            return(db);
        }
Beispiel #2
0
        public static MockDbContext GetDbContext(bool withData = true)
        {
            var options = new DbContextOptionsBuilder().UseInMemoryDatabase("dbtest").Options;
            var db      = new MockDbContext(options);

            if (withData)
            {
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 1", Price = 10, Topping = "Champignon"
                });
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 2", Price = 11, Topping = "Champignon"
                });
                db.Pizzas.Add(new PizzaMock {
                    Name = "Pizza 3", Price = 12, Topping = "Champignon"
                });

                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0654788906", Lastname = "Fuente", Firstname = "Izaaac", Address = "Ivry", ZipCode = "12098", City = "NewYork"
                });
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0654786512", Lastname = "Rach", Firstname = "David", Address = "Choisy", ZipCode = "98065", City = "Chicago"
                });
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "0654780432", Lastname = "Sidney", Firstname = "Jean", Address = "Paris", ZipCode = "45097", City = "USA"
                });

                db.SaveChanges();
            }

            return(db);
        }
        public static MockDbContext GetDbContext(bool withData = true)
        {
            var options = new DbContextOptionsBuilder().UseInMemoryDatabase("dbtest").Options;
            var db      = new MockDbContext(options);

            if (withData)
            {
                db.Customers.Add(new CustomerMock {
                    Email = "*****@*****.**", Phone = "65421895154", Lastname = "Charles", Firstname = "Clementine",
                    Genre = "Homme", Address = null, ZipCode = "6854", City = "Limoges",
                });

                db.Customers.Add(new CustomerMock
                {
                    Email = "*****@*****.**", Phone = "65421895154", Lastname = "Charles", Firstname = "Zan",
                    Genre = "Homme", Address = null, ZipCode = "6854", City = "Limoges",
                });

                db.Customers.Add(new CustomerMock
                {
                    Email = "*****@*****.**", Phone = "65421895154", Lastname = "Kaly", Firstname = "Moli",
                    Genre = "Femme", Address = null, ZipCode = "6854", City = "Limoges",
                });

                db.Customers.Add(new CustomerMock
                {
                    Email = "*****@*****.**", Phone = "65421895154", Lastname = "Charles", Firstname = "Jeep",
                    Genre = "Femme", Address = null, ZipCode = "6854", City = "Limoges",
                });


                db.SaveChanges();
            }

            return(db);
        }