Ejemplo n.º 1
0
        public void PostTaskTest_VerifyResponseNotNull()
        {
            IRestResponse <TaskList> restResponse = new RestResponse <TaskList>();

            _mockedRestClient.Setup(x => x.Execute <TaskList>(It.IsAny <IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = GetTestTask();

            var response = taskApiRepository.PostTask(task);

            Assert.IsNotNull(response);
        }
Ejemplo n.º 2
0
        public void PostTaskTest__VerifyExecuteCalledOnce()
        {
            IRestResponse <TaskList> restResponse = new RestResponse <TaskList>();

            _mockedRestClient.Setup(x => x.Execute <TaskList>(It.IsAny <IRestRequest>())).Returns(restResponse);

            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = GetTestTask();

            var response = taskApiRepository.PostTask(task);

            _mockedRestClient.Verify(x => x.Execute <TaskList>(It.IsAny <IRestRequest>()), Times.Once());
        }
Ejemplo n.º 3
0
        public void PostTaskTest_ResponseNull_VerifyExceptionThrown()
        {
            IRestResponse <TaskList> restResponse = null;

            _mockedRestClient.Setup(x => x.Execute <TaskList>(It.IsAny <IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = TestHelper.GetTestTask();

            Should.Throw <Exception>
            (
                () => taskApiRepository.PostTask(task)
            );
        }
Ejemplo n.º 4
0
        public void PostTaskTest__VerifyReturnsResponseStatusCodeIsCreated()
        {
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Created;

            IRestResponse <TaskList> restResponse = new RestResponse <TaskList>();

            restResponse.StatusCode = HttpStatusCode.Created;

            _mockedRestClient.Setup(x => x.Execute <TaskList>(It.IsAny <IRestRequest>())).Returns(restResponse);

            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = GetTestTask();

            var actualStatusCode = taskApiRepository.PostTask(task);

            Assert.AreEqual(expectedStatusCode, actualStatusCode);
        }
Ejemplo n.º 5
0
        public void PostTaskTest_ResponseNull_VerifyExceptionThrown()
        {
            IRestResponse <TaskList> restResponse = null;
            var exceptionThrown = false;

            _mockedRestClient.Setup(x => x.Execute <TaskList>(It.IsAny <IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = GetTestTask();

            try
            {
                var response = taskApiRepository.PostTask(task);
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }
Ejemplo n.º 6
0
        public void PostTaskTest__VerifyReturnsResponseStatusCodeIsCreated()
        {
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Created;

            IRestResponse<TaskList> restResponse = new RestResponse<TaskList>();
            restResponse.StatusCode = HttpStatusCode.Created;

            _mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);

            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = TestHelper.GetTestTask();

            var actualStatusCode = taskApiRepository.PostTask(task);

               expectedStatusCode.ShouldBe(actualStatusCode);
        }
Ejemplo n.º 7
0
        public void PostTaskTest__VerifyExecuteCalledOnce()
        {
            IRestResponse<TaskList> restResponse = new RestResponse<TaskList>();

            _mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);

            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = TestHelper.GetTestTask();

            var response = taskApiRepository.PostTask(task);

            _mockedRestClient.Verify(x => x.Execute<TaskList>(It.IsAny<IRestRequest>()), Times.Once());
        }
Ejemplo n.º 8
0
        public void PostTaskTest_VerifyResponseNotNull()
        {
            IRestResponse<TaskList> restResponse = new RestResponse<TaskList>();

            _mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = TestHelper.GetTestTask();

            var response = taskApiRepository.PostTask(task);

            response.ShouldNotBeNull();
        }
Ejemplo n.º 9
0
        public void PostTaskTest_ResponseNull_VerifyExceptionThrown()
        {
            IRestResponse<TaskList> restResponse = null;

            _mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(_mockedRestClient.Object);

            var task = TestHelper.GetTestTask();

            Should.Throw<Exception>
            (
                () => taskApiRepository.PostTask(task)
            );
        }
        public void PostTaskTest__VerifyReturnsResponseStatusCodeIsCreated()
        {
            HttpStatusCode expectedStatusCode = HttpStatusCode.Created;
            HttpStatusCode actualStatusCode;

            IRestResponse<TaskList> restResponse = new RestResponse<TaskList>();
            restResponse.StatusCode = HttpStatusCode.Created;

            mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);

            var taskApiRepository = new TaskApiRepository(mockedRestClient.Object);

            Task task = GetTestTask();

            actualStatusCode = taskApiRepository.PostTask(task);

            Assert.AreEqual(expectedStatusCode, actualStatusCode);
        }
        public void PostTaskTest_VerifyResponseNotNull()
        {
            IRestResponse<TaskList> restResponse = new RestResponse<TaskList>();

            mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(mockedRestClient.Object);

            Task task = GetTestTask();

            HttpStatusCode response = taskApiRepository.PostTask(task);

            Assert.IsNotNull(response);
        }
        public void PostTaskTest_ResponseNull_VerifyExceptionThrown()
        {
            IRestResponse<TaskList> restResponse = null;
            bool exceptionThrown = false;

            mockedRestClient.Setup(x => x.Execute<TaskList>(It.IsAny<IRestRequest>())).Returns(restResponse);
            var taskApiRepository = new TaskApiRepository(mockedRestClient.Object);

            Task task = GetTestTask();

            try
            {
                HttpStatusCode response = taskApiRepository.PostTask(task);
            }
            catch (Exception)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown);
        }