コード例 #1
0
        public void CustomerSearch()
        {
            var mockData = new MockData
            {
                Users = new List <User>
                {
                    new User
                    {
                        id            = 1,
                        customer_code = "c1",
                        Roles         = new List <Role>
                        {
                            new Role {
                                id = Role.Admin
                            }
                        }
                    },
                    new User
                    {
                        id            = 2,
                        customer_code = "c2",
                        Roles         = new List <Role>
                        {
                            new Role {
                                id = Role.User
                            }
                        }
                    },
                    new User
                    {
                        id            = 3,
                        customer_code = "c2",
                        Roles         = new List <Role>
                        {
                            new Role {
                                id = Role.BranchAdmin
                            }
                        }
                    }
                },
                Customers = new List <Customer>
                {
                    new Customer
                    {
                        code     = "c1",
                        name     = "",
                        address6 = "adr 1"
                    },
                    new Customer
                    {
                        code             = "c3",
                        address6         = "adr 2",
                        name             = "xx",
                        invoice_customer = "c2"
                    },
                    new Customer
                    {
                        code     = "c2",
                        name     = "yy",
                        address6 = "adr 3"
                    },
                    new Customer
                    {
                        code             = "c4",
                        invoice_customer = "c2",
                        analysis_codes_1 = "CLOSED",
                        address6         = "",
                        name             = "zz"
                    },
                    new Customer
                    {
                        code     = "n1",
                        name     = "xxcyy",
                        address6 = ""
                    }
                }
            };

            unitOfWork.Data = mockData;
            controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "1");
            var customers = controller.CustomerSearch("c", null);

            TestCollection(customers, 5);

            customers = controller.CustomerSearch("2", Role.User);
            TestCollection(customers, 2);

            customers = controller.CustomerSearch("dr", Role.User);
            TestCollection(customers, 3);

            controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "3");
            customers = controller.CustomerSearch("c", Role.User);
            TestCollection(customers, 1);
        }