public void Initialize()
        {
            var customer1 = new Customer()
            {
                CustomerId = 0,
                Name       = "Jan Kowalski",
                Email      = "*****@*****.**",
                Address    = "Akacjowa 2",
                Telephone  = "123456789"
            };
            var customer2 = new Customer()
            {
                CustomerId = 1,
                Name       = "Piotr Nowak",
                Email      = "*****@*****.**",
                Address    = "Klonowa 42",
                Telephone  = "555555555"
            };
            var customer3 = new Customer()
            {
                CustomerId = 2,
                Name       = "Katarzyna Malinowska",
                Email      = "*****@*****.**",
                Address    = "Brzozowa 121",
                Telephone  = "987654321"
            };
            var customers = new List <Customer>
            {
                customer1,
                customer2,
                customer3
            };

            var orders = new List <Order>()
            {
                new Order()
                {
                    Chef             = null,
                    Deliveryman      = null,
                    CookingDeadline  = DateTime.Parse("15/11/2017 9:00"),
                    CustomerWish     = "Nie takie przypieczone",
                    Customer         = customer1,
                    DeliveryDeadline = DateTime.Parse("15/11/2017 9:30"),
                    OrderCreated     = DateTime.Parse("2/11/2017 19:00"),
                    OrderedProducts  = new List <CustomizedProduct>(),
                    TotalPrice       = 23 + 16,
                    OrderStatus      = OrderStatus.Pending,
                },
                new Order()
                {
                    Chef             = null,
                    Deliveryman      = null,
                    CookingDeadline  = DateTime.Parse("15/11/2017 13:00"),
                    CustomerWish     = "Poproszę bez sera",
                    Customer         = customer2,
                    DeliveryDeadline = DateTime.Parse("15/11/2017 13:30"),
                    OrderCreated     = DateTime.Parse("2/11/2017 14:00"),
                    OrderedProducts  = new List <CustomizedProduct>(),
                    TotalPrice       = 16,
                    OrderStatus      = OrderStatus.Pending,
                }
            };

            var contextMock   = new Mock <EntityDataModel>();
            var customersMock = MockedDatabaseUtils.CreateDbSetMock(customers);
            var ordersMock    = MockedDatabaseUtils.CreateDbSetMock(orders);

            contextMock.Setup(foo => foo.Customers).Returns(customersMock.Object);
            contextMock.Setup(foo => foo.Orders).Returns(ordersMock.Object);

            context = contextMock.Object;
        }
Beispiel #2
0
        public void Initialize()
        {
            var customer1 = new Customer()
            {
                CustomerId = 1,
                Name       = "Jan Kowalski",
                Email      = "*****@*****.**",
                Address    = "Akacjowa 2",
                Telephone  = "123456789"
            };
            var customer2 = new Customer()
            {
                CustomerId = 2,
                Name       = "Piotr Nowak",
                Email      = "*****@*****.**",
                Address    = "Klonowa 42",
                Telephone  = "555555555"
            };
            var customer3 = new Customer()
            {
                CustomerId = 3,
                Name       = "Katarzyna Malinowska",
                Email      = "*****@*****.**",
                Address    = "Brzozowa 121",
                Telephone  = "987654321"
            };
            var customers = new List <Customer>
            {
                customer1,
                customer2,
                customer3
            };


            var chef1 = new Employee()
            {
                EmployeeId = 1,
                Address    = "Mieszkalna 123",
                BirthDate  = DateTime.Parse("10/10/1950"),
                Category   = null,
                Email      = "*****@*****.**",
                Name       = "John Smith",
                Salary     = 1234500,
                Telephone  = "123-125-865",
                ProductCategoryCompetency = new List <ProductCategory>(),
                AvailableIntervals        = new List <TimeInterval>()
            };

            var chef2 = new Employee()
            {
                EmployeeId = 2,
                Address    = "Wypiekalna 123",
                BirthDate  = DateTime.Parse("10/10/1980"),
                Category   = null,
                Email      = "*****@*****.**",
                Name       = "Adam Bezier",
                Salary     = 4624500,
                Telephone  = "437-355-124",
                ProductCategoryCompetency = new List <ProductCategory>(),
                AvailableIntervals        = new List <TimeInterval>()
            };

            var deliveryman1 = new Employee()
            {
                EmployeeId         = 3,
                Address            = "Dostarczalna 3",
                BirthDate          = DateTime.Parse("10/10/1990"),
                Category           = null,
                Email              = "*****@*****.**",
                Name               = "Alfred Courier",
                Salary             = 1224500,
                Telephone          = "214-514-243",
                AvailableIntervals = new List <TimeInterval>()
            };

            var employees = new List <Employee>()
            {
                chef1,
                chef2,
                deliveryman1
            };

            var customizedProducts = new List <CustomizedProduct>()
            {
                new CustomizedProduct()
                {
                    CustomizedProductId = 1,
                    Toppings            = new List <Topping>(),
                    BaseProduct         = new Product()
                    {
                        ProductId = 1
                    }
                },
                new CustomizedProduct()
                {
                    CustomizedProductId = 2,
                    Toppings            = new List <Topping>(),
                    BaseProduct         = new Product()
                    {
                        ProductId = 2
                    }
                }
            };

            var orders = new List <Order>()
            {
                new Order()
                {
                    OrderId          = 1,
                    Chef             = chef1,
                    Deliveryman      = deliveryman1,
                    CookingDeadline  = DateTime.Parse("15/11/2017 9:00"),
                    CustomerWish     = "Nie takie przypieczone",
                    Customer         = customer1,
                    DeliveryDeadline = DateTime.Parse("15/11/2017 9:30"),
                    OrderCreated     = DateTime.Parse("2/11/2017 19:00"),
                    OrderedProducts  = new List <CustomizedProduct>()
                    {
                        customizedProducts[0]
                    },
                    TotalPrice  = 23 + 16,
                    OrderStatus = OrderStatus.Pending,
                },
                new Order()
                {
                    OrderId          = 2,
                    Chef             = chef2,
                    Deliveryman      = deliveryman1,
                    CookingDeadline  = DateTime.Parse("15/11/2017 13:00"),
                    CustomerWish     = "Poproszę bez sera",
                    Customer         = customer2,
                    DeliveryDeadline = DateTime.Parse("15/11/2017 13:30"),
                    OrderCreated     = DateTime.Parse("2/11/2017 14:00"),
                    OrderedProducts  = new List <CustomizedProduct>()
                    {
                        customizedProducts[1]
                    },
                    TotalPrice  = 16,
                    OrderStatus = OrderStatus.Pending,
                }
            };


            var contextMock            = new Mock <EntityDataModel>();
            var employeesMock          = MockedDatabaseUtils.CreateDbSetMock(employees);
            var customersMock          = MockedDatabaseUtils.CreateDbSetMock(customers);
            var customizedProductsMock = MockedDatabaseUtils.CreateDbSetMock(customizedProducts);
            var ordersMock             = MockedDatabaseUtils.CreateDbSetMock(orders);

            contextMock.Setup(c => c.Employees).Returns(employeesMock.Object);
            contextMock.Setup(c => c.Customers).Returns(customersMock.Object);
            contextMock.Setup(c => c.CustomizedProducts).Returns(customizedProductsMock.Object);
            contextMock.Setup(c => c.Orders).Returns(ordersMock.Object);
            context = contextMock.Object;
            filter  = new OrdersFilter(context);
        }