예제 #1
0
        public bool MyAction(ODataActionParameters parameters)
        {
            Assert.True(parameters.ContainsKey("Customer"));
            ODataActionTests.Customer customer = parameters["Customer"] as ODataActionTests.Customer;
            Assert.NotNull(customer);
            Assert.Equal(101, customer.ID);
            Assert.Equal("Avatar", customer.Name);

            Assert.True(parameters.ContainsKey("Customers"));
            ValidateCustomers((parameters["Customers"] as IEnumerable <ODataActionTests.Customer>).ToList());

            return(true);
        }
예제 #2
0
        private void ValidateCustomers(IList <ODataActionTests.Customer> customers)
        {
            Assert.NotNull(customers);
            Assert.Equal(2, customers.Count);

            ODataActionTests.Customer customer = Assert.IsType <ODataActionTests.Customer>(customers[0]);
            Assert.NotNull(customer);
            Assert.Equal(901, customer.ID);
            Assert.Equal("John", customer.Name);

            ODataActionTests.SubCustomer subCustomer = Assert.IsType <ODataActionTests.SubCustomer>(customers[1]);
            Assert.NotNull(subCustomer);
            Assert.Equal(902, subCustomer.ID);
            Assert.Equal("Mike", subCustomer.Name);
            Assert.Equal(9.9, subCustomer.Price);
        }