Example #1
0
        public async Task DeleteSession_SessionTokenIsNull_BadRequest()
        {
            // Arrange
            var httpClientProvider = new TestHttpClientProvider(request => new HttpResponseMessage(HttpStatusCode.OK));

            var controller = new SessionsController(new AuthenticationRepository(), httpClientProvider, _logMock.Object)
            {
                Request = new HttpRequestMessage()
            };

            // Act
            IHttpActionResult result = await controller.DeleteSession();

            // Assert
            Assert.IsInstanceOfType(result, typeof(BadRequestResult));
        }
Example #2
0
        public async Task DeleteSession_Exception_InternalServerErrorResult()
        {
            // Arrange
            var httpRequestMessage = new HttpRequestMessage();

            httpRequestMessage.Headers.Add("Session-Token", Guid.NewGuid().ToString());

            var httpClientProvider = new TestHttpClientProvider(request => { throw new Exception(); });

            var controller = new SessionsController(new AuthenticationRepository(), httpClientProvider, _logMock.Object)
            {
                Request = httpRequestMessage
            };

            // Act
            IHttpActionResult result = await controller.DeleteSession();

            // Assert
            Assert.IsInstanceOfType(result, typeof(InternalServerErrorResult));
        }
Example #3
0
        public async Task DeleteSession_SessionNotFound_ResponseMessageResult()
        {
            // Arrange
            var httpRequestMessage = new HttpRequestMessage();

            httpRequestMessage.Headers.Add("Session-Token", Guid.NewGuid().ToString());

            var httpClientProvider = new TestHttpClientProvider(request => new HttpResponseMessage(HttpStatusCode.NotFound));

            var controller = new SessionsController(new AuthenticationRepository(), httpClientProvider, _logMock.Object)
            {
                Request = httpRequestMessage
            };

            // Act
            IHttpActionResult result = await controller.DeleteSession();

            // Assert
            Assert.IsInstanceOfType(result, typeof(ResponseMessageResult));
        }