コード例 #1
0
        public void AddNewTaskTest()
        {
            testList.Id = Guid.NewGuid();
            var jsonNewList = testList.SerializeJson();

            TestHelper.SendPost(TestHelper.REST_SERVICE_START_URL + $"lists/new",
                                jsonNewList,
                                out HttpStatusCode statusCode,
                                out string description);

            Assert.AreEqual(201, (int)statusCode);

            testTask.Id = Guid.NewGuid();
            var jsonNewTask = testTask.SerializeJson();

            TestHelper.SendPost(TestHelper.REST_SERVICE_START_URL + $"list/{testList.Id}/tasks",
                                jsonNewTask,
                                out HttpStatusCode statusCode1,
                                out string description1);

            Assert.AreEqual(201, (int)statusCode1);

            var json = TestHelper.SendGet(TestHelper.REST_SERVICE_START_URL + "list/" + testList.Id);

            var result = json.DeserializeJson <ToDoList>();

            Assert.IsNotNull(result);
            Assert.AreEqual(testList.Id, result.Id);
            Assert.IsTrue(result.ToDoTasks.Any(t => t.Id == testTask.Id));
        }