Пример #1
0
        public void ServiceFunctions_DeleteService_InvokesNextFunctionWhenPathNotCorrect()
        {
            // Arrange
            var request = new TestHttpRequest()
            {
                Method = "GET",
                // This path causes the request not to match the required pattern.
                Path       = "/__vs/badResource/ab61870e-8427-ae57effd5c6a",
                BodyString = string.Empty
            };
            var response = new TestHttpResponse();
            var context  = new TestHttpContext(request, response);

            var numCallsToNext = 0;

            Task next()
            {
                numCallsToNext++;
                return(Task.CompletedTask);
            }

            // Act
            ServiceFunctions.DeleteService(context, next).Wait();

            // Assert
            Assert.AreEqual(1, numCallsToNext);
        }
Пример #2
0
        public void ServiceFunctions_DeleteService_ThrowsOnNullNextFunction()
        {
            // Arrange
            HttpContext context          = new TestHttpContext();
            Func <Task> nullNextFunction = null;

            // Act
            ServiceFunctions.DeleteService(context, nullNextFunction).Wait();
        }
Пример #3
0
        public void ServiceFunctions_DeleteService_ThrowsOnNullContext()
        {
            // Arrange
            HttpContext nullContext = null;

            Task next() => Task.CompletedTask;

            // Act
            ServiceFunctions.DeleteService(nullContext, next).Wait();
        }
Пример #4
0
        public void ServiceFunctions_DeleteService_ReturnsOk()
        {
            // Arrange
            var request = new TestHttpRequest()
            {
                Method     = "DELETE",
                Path       = "/__vs/services/ab61870e-793a-4c10-8427-ae57effd5c6a",
                BodyString = string.Empty
            };
            var response = new TestHttpResponse();
            var context  = new TestHttpContext(request, response);

            Task next() => Task.CompletedTask;

            // Act
            ServiceFunctions.DeleteService(context, next).Wait();

            // Assert
            Assert.AreEqual(200, response.StatusCode);
        }
Пример #5
0
        public void ServiceFunctions_DeleteServices_ReturnsNotFoundAfterDeleting()
        {
            // Arrange
            var serviceId = AddService("GET", "/api/resource/5be5223c-70d4-4a61-af5c-be5d60d9eb65");

            var request = new TestHttpRequest()
            {
                Method     = "DELETE",
                Path       = "/__vs/services/" + serviceId,
                BodyString = string.Empty
            };
            var response = new TestHttpResponse();
            var context  = new TestHttpContext(request, response);

            Task next() => Task.CompletedTask;

            // Act
            ServiceFunctions.DeleteService(context, next).Wait();

            // Assert
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(404, InvokeService("GET", "/api/resource/5be5223c-70d4-4a61-af5c-be5d60d9eb65"));
        }