Пример #1
0
        public async Task InjestRequest_NotPost(string method)
        {
            // Setup
            var context = new DefaultHttpContext();

            context.Request.Method = method;

            // Test
            var service = new DefaultInjestionService(new TriggerService(), eventQueueStore, logger);
            var result  = await service.InjestRequest(context);

            // Assert
            Assert.AreEqual(405, result.StatusCode, "Method not allowed not set");
        }
Пример #2
0
        public async Task InjestRequest_NotJsonType(string contentType)
        {
            // Setup
            var context = new DefaultHttpContext();

            context.Request.Method      = "POST";
            context.Request.ContentType = contentType;

            // Test
            var service = new DefaultInjestionService(new TriggerService(), eventQueueStore, logger);
            var result  = await service.InjestRequest(context);

            // Assert
            Assert.AreEqual(415, result.StatusCode, "Unsupported Media Type not set");
        }
Пример #3
0
        public async Task InjestReqest_ValidMessage(string body)
        {
            // Setup
            var context = new DefaultHttpContext();

            context.Request.Method      = "POST";
            context.Request.ContentType = "application/json";
            context.Request.Body        = new MemoryStream(Encoding.UTF8.GetBytes(body));

            // Test
            var service = new DefaultInjestionService(new TriggerService(), eventQueueStore, logger);
            var result  = await service.InjestRequest(context);

            // Assert
            Assert.AreEqual(202, result.StatusCode, "Bad Request not set");
        }