Пример #1
0
        public void TestProject()
        {
            ParentController oController = new ParentController();



            HttpResponseMessage res = oController.Get();
            string message          = pResult.status.Message;

            Assert.AreEqual("Project added successfully", message);
            testProject.Project_ID = pResult.project.Project_ID;
            Assert.AreEqual("Project updated successfully", oController.Post(testProject).status.Message);
            Assert.IsNotNull(oController.Get());
        }
Пример #2
0
        public void ParentGetBenchMark(BenchmarkContext context)
        {
            ParentController parent = new ParentController();

            parent.Request = new HttpRequestMessage();
            parent.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            parent.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage _http;

            _http = parent.Get();
            parentCounter.Increment();
        }
        public void GetTasksByID(Parent _task)
        {
            //tets get by id
            ParentController p = new ParentController();

            p.Request = new HttpRequestMessage();
            p.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            p.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage _http;

            _http = p.Get(_task.Parent_Id);
            Assert.AreEqual(HttpStatusCode.OK, _http.StatusCode);
        }
        public void GetParentByIDNULLCheck(Parent pro)
        {
            var context = new TaskTestContext();

            context.Parent.Add(pro);
            ParentController controller = new ParentController(context);

            controller.Request = new HttpRequestMessage();
            controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            controller.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage http;

            http = controller.Get(-1);
            Assert.AreEqual(HttpStatusCode.NotFound, http.StatusCode);
        }
        public void GetTasks()
        {
            //test get
            ParentController p = new ParentController();

            p.Request = new HttpRequestMessage();
            p.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            p.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage _http;

            try {
                _http = p.Get();
                Assert.AreEqual(HttpStatusCode.OK, _http.StatusCode);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message.Contains("Error"));
            }
        }
        public void PostPost(Parent _task)
        {
            //test post
            _task.Parent_Id = 0;
            ParentController p = new ParentController();

            p.Request = new HttpRequestMessage();
            p.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            p.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage _http;

            _http = p.Post(_task);
            Assert.AreEqual(HttpStatusCode.Created, _http.StatusCode);
            Assert.GreaterOrEqual(_task.Parent_Id, 0);
            //test get by id
            _http = p.Get(_task.Parent_Id);
            Assert.AreEqual(HttpStatusCode.OK, _http.StatusCode);
            Assert.GreaterOrEqual(_task.Parent_Id, 0);
            //test delete
            _http = p.Delete(_task);
            Assert.AreEqual(HttpStatusCode.OK, _http.StatusCode);
        }
        public void GetParentByID(Parent pro)
        {
            var context = new TaskTestContext();

            context.Parent.Add(pro);
            ParentController controller = new ParentController(context);

            controller.Request = new HttpRequestMessage();
            controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            controller.Request.SetConfiguration(new HttpConfiguration());
            HttpResponseMessage http;

            http = controller.Get(pro.Parent_Id);
            Assert.AreEqual(HttpStatusCode.OK, http.StatusCode);
            var response = http.Content.ReadAsStringAsync().Result
                           .Replace("\\", "")
                           .Trim(new char[1] {
                '"'
            });
            List <Parent> _list = JsonConvert.DeserializeObject <List <Parent> >(response);

            Assert.IsNotNull(_list);
            Assert.AreEqual(pro.Parent_Id, _list[0].Parent_Id);
        }