コード例 #1
0
        public void TestDataShapingForListResponse()
        {
            TestApiController testController = new TestApiController();
            List<TestContract> contracts = new List<TestContract>();
            contracts.Add(new TestContract("1", "name 1", "description 1"));
            contracts.Add(new TestContract("2", "name 2", "description 2"));
            contracts.Add(new TestContract("3", "name 3", "description 3"));

            testController.RequiredFields = new List<string>();
            testController.RequiredFields.Add("Name");

            var processedResponses = testController.TestProcessListsResponse<TestContract>(contracts) ;

            for (int i = 0; i < contracts.Count; i++)
            {
                var processedResponse = processedResponses[i] as IDictionary<string, object>;
                Assert.IsFalse(processedResponse.ContainsKey("ID"));
                Assert.AreEqual(processedResponse["Name"], contracts[i].Name);
                Assert.IsFalse(processedResponse.ContainsKey("Description"));
            }
        }