Ejemplo n.º 1
0
        public void ServiceFunctions_DeleteAllServices_ReturnsNotFoundAfterDeleting()
        {
            // Arrange
            var service1Id = AddService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90001");
            var service2Id = AddService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90002");
            var service3Id = AddService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90003");

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

            Task next() => Task.CompletedTask;

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

            // Assert
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(404, InvokeService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90001"),
                            "Invoking service1 should result in a 404.");
            Assert.AreEqual(404, InvokeService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90002"),
                            "Invoking service2 should result in a 404.");
            Assert.AreEqual(404, InvokeService("GET", "/api/resource/5be5223c-70d4-4a61-aa5c-be5d60d90003"),
                            "Invoking service3 should result in a 404.");
        }
Ejemplo n.º 2
0
        public void ServiceFunctions_DeleteAllServices_ThrowsOnNullNextFunction()
        {
            // Arrange
            var         context          = new TestHttpContext();
            Func <Task> nullNextFunction = null;

            // Act
            ServiceFunctions.DeleteAllServices(context, nullNextFunction).Wait();
        }
Ejemplo n.º 3
0
        public void ServiceFunctions_DeleteAllServices_ThrowsOnNullContext()
        {
            // Arrange
            HttpContext nullContext = null;

            Task next() => Task.CompletedTask;

            // Act
            ServiceFunctions.DeleteAllServices(nullContext, next).Wait();
        }
Ejemplo n.º 4
0
        public void ServiceFunctions_DeleteAllServices_ReturnsOk()
        {
            // Arrange
            var request = new TestHttpRequest()
            {
                Method     = "DELETE",
                Path       = "/__vs/services",
                BodyString = string.Empty
            };
            var response = new TestHttpResponse();
            var context  = new TestHttpContext(request, response);

            Task next() => Task.CompletedTask;

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

            // Assert
            Assert.AreEqual(200, response.StatusCode);
        }