Пример #1
0
        public async Task EchoModelA_POST()
        {
            var jsonToSend = new Controllers.ModelA
            {
                ID   = "xz1234",
                Name = "Alexz Tester",
                DOB  = new DateTime(1980, 8, 15)
            }.ToJson(JsonWritingOptions.CompactRowsAsMap);

            var content = new StringContent(
                jsonToSend,
                System.Text.Encoding.UTF8,
                ContentType.JSON);

            var response = await Client.PostAsync("echomodela", content);

            Aver.IsTrue(HttpStatusCode.OK == response.StatusCode);

            Aver.AreEqual(ContentType.JSON, response.Content.Headers.ContentType.MediaType);

            var got = (await response.Content.ReadAsStringAsync()).JsonToDataObject() as JsonDataMap;

            Aver.IsNotNull(got);

            var data = JsonReader.ToDoc <Controllers.ModelA>(got);

            Aver.IsNotNull(data);
            Aver.AreEqual("xz1234", data.ID);
            Aver.AreEqual("Alexz Tester", data.Name);
            Aver.IsNotNull(data.DOB);
            Aver.AreEqual(1980, data.DOB.Value.Year);
            Aver.AreEqual(8, data.DOB.Value.Month);
            Aver.AreEqual(15, data.DOB.Value.Day);
        }
Пример #2
0
 [Action] //AZ #520
 public object EchoMixModelA(string id, string another, ModelA model) => new { id, another, model };
Пример #3
0
 public object EchoModelA(ModelA got) => got;