public void SetupTests()
        {
            context = new Mock <ClockContext>();
            List <User> userList = new List <User>
            {
                new User {
                    userId = 1, firstName = "BillTest", lastName = "WeasleyTest", email = "*****@*****.**", password = "******", repeatPassword = "******"
                },
                new User {
                    userId = 2, firstName = "CharlieTest", lastName = "WeasleyTest", email = "*****@*****.**", password = "******", repeatPassword = "******"
                }
            };

            customerList = new List <Customer>
            {
                new Customer {
                    userId = 1, customerId = 1, firstName = "HarryTest", lastName = "PotterTest", status = CustomerStatus.Active
                },
                new Customer {
                    userId = 1, customerId = 2, firstName = "HermioneTest", lastName = "GrangerTest", status = CustomerStatus.Active
                },
                new Customer {
                    userId = 2, customerId = 3, firstName = "RonTest", lastName = "WeasleyTest", status = CustomerStatus.Active
                }
            };

            projectList = new List <Project>
            {
                new Project {
                    userId = 1, customerId = 1, projectId = 1, name = "Quidditch", startDate = DateTime.Parse("2017-06-14"), expectedEndDate = DateTime.Parse("2017-08-14"), status = ProjectStatus.InProgress, timeSpentInHours = 20, customer = customerList.Where(c => c.customerId == 1).FirstOrDefault()
                },
                new Project {
                    userId = 2, customerId = 3, projectId = 2, name = "Fantastic Beasts", startDate = DateTime.Parse("2017-07-14"), expectedEndDate = DateTime.Parse("2018-08-14"), status = ProjectStatus.InProgress, timeSpentInHours = 5, customer = customerList.Where(c => c.customerId == 3).FirstOrDefault()
                }
            };
            context.Setup(c => c.Set <User>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(userList));
            context.Setup(c => c.Set <Customer>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(customerList));

            Func <Project, int> getClassId = project1 => project1.projectId;

            context.Setup(c => c.Set <Project>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(projectList, getClassId));


            var uow = new UnitOfWork(context.Object);

            homeController = new HomeController(uow);
            homeController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
            customerController = new CustomerController(uow);
            customerController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
            projectController = new ProjectController(uow);
            projectController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
        }
Пример #2
0
        public void SetupTests()
        {
            context  = new Mock <ClockContext>();
            userList = new List <User>
            {
                new User {
                    firstName = "BillTest", lastName = "WeasleyTest", email = "*****@*****.**", password = "******", repeatPassword = "******"
                }
            };
            context.Setup(c => c.Set <User>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(userList));

            var uow = new UnitOfWork(context.Object);

            homeController = new HomeController(uow);
            homeController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
        }
Пример #3
0
        public void SetupTests()
        {
            context  = new Mock <ClockContext>();
            userList = new List <User>
            {
                new User {
                    userId = 1, firstName = "BillTest", lastName = "WeasleyTest", email = "*****@*****.**", password = "******", repeatPassword = "******"
                },
                new User {
                    userId = 2, firstName = "CharlieTest", lastName = "WeasleyTest", email = "*****@*****.**", password = "******", repeatPassword = "******"
                }
            };
            customerList = new List <Customer>
            {
                new Customer {
                    userId = 1, customerId = 1, firstName = "HarryTest", lastName = "PotterTest", status = CustomerStatus.Active
                },
                new Customer {
                    userId = 1, customerId = 2, firstName = "HermioneTest", lastName = "GrangerTest", status = CustomerStatus.Active
                },
                new Customer {
                    userId = 2, customerId = 3, firstName = "RonTest", lastName = "WeasleyTest", status = CustomerStatus.Active
                }
            };
            context.Setup(c => c.Set <User>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(userList));

            Func <Customer, int> getClassId = customer1 => customer1.customerId;

            context.Setup(c => c.Set <Customer>()).Returns(() => UnitTestsHelper.GetQueryableMockDbSet(customerList, getClassId));

            var uow = new UnitOfWork(context.Object);

            homeController = new HomeController(uow);
            homeController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
            customerController = new CustomerController(uow);
            customerController.ControllerContext = UnitTestsHelper.GetContextBase().Object;
        }