Пример #1
0
        public void DeleteResponse()
        {
            List <Todo> oldTodos = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                                   .GetModelAsync <List <Todo> >().Result;

            Assert.IsTrue(oldTodos != null && oldTodos.Count > 0);

            int oldCount = oldTodos.Count;

            Todo first = oldTodos.FirstOrDefault();

            HttpResponseMessage result = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                                         .DeleteResponseAsync(first.Id).Result;

            Assert.IsTrue(result.IsSuccessStatusCode);

            List <Todo> newTodos = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                                   .GetModelAsync <List <Todo> >().Result;

            Assert.IsTrue(newTodos != null && newTodos.Count > 0);

            int newCount = newTodos.Count;

            Assert.IsTrue(newCount < oldCount);
        }
Пример #2
0
        public void GetModel()
        {
            List <Todo> todos = new Unicorn(new UnicornConfig(Constants.URL)).GetModelAsync <List <Todo> >().Result;

            Assert.IsTrue(todos != null && todos.Count > 0);

            Todo model = new Unicorn(new UnicornConfig(Constants.URL + "/" + todos.FirstOrDefault().Id)).GetModelAsync <Todo>().Result;

            Assert.IsNotNull(model);
            Assert.IsTrue(model.Id > 0);
        }
Пример #3
0
        public void DeleteJson()
        {
            List <Todo> oldTodos = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                                   .GetModelAsync <List <Todo> >().Result;

            Assert.IsTrue(oldTodos != null && oldTodos.Count > 0);

            int oldCount = oldTodos.Count;

            Todo first = oldTodos.FirstOrDefault();

            string result = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                            .DeleteStringAsync(first.Id).Result;

            List <Todo> newTodos = new Unicorn(UnicornConfigFactory.NewInstance(Constants.URL))
                                   .GetModelAsync <List <Todo> >().Result;

            Assert.IsTrue(newTodos != null && newTodos.Count > 0);

            int newCount = newTodos.Count;

            Assert.IsTrue(newCount < oldCount);
        }