コード例 #1
0
        public async void ConnectionNotFoundSendsReload()
        {
            var http     = new Mock <HttpContext>();
            var request  = new Mock <HttpRequest>();
            var cookies  = new Mock <IRequestCookieCollection>();
            var response = new Mock <HttpResponse>();
            var headers  = new Mock <IHeaderDictionary>();
            var body     = new Mock <Stream>();
            var sockets  = new Mock <WebSocketManager>();

            http.Setup(x => x.Request).Returns(request.Object);
            http.Setup(x => x.Response).Returns(response.Object);
            http.Setup(x => x.WebSockets).Returns(sockets.Object);
            request.Setup(x => x.Method).Returns("POST");
            request.Setup(x => x.Path).Returns("/_event");
            request.Setup(x => x.Cookies).Returns(cookies.Object);
            response.Setup(x => x.Headers).Returns(headers.Object);
            response.Setup(x => x.Body).Returns(body.Object);
            sockets.Setup(x => x.IsWebSocketRequest).Returns(false);
            var query = new MyQueryCollection();

            request.Setup(x => x.Query).Returns(query);
            query.Add("doc", "EF2FF98720E34A2EA29E619977A5F04A");
            query.Add("el", "lala");
            query.Add("ev", "lala");
            var next    = new Mock <RequestDelegate>();
            var handler = new PostEventHandler(Context.Application, next.Object);
            var result  = await handler.ProcessRequest(http.Object);

            Assert.True(result);
        }
コード例 #2
0
        public async void PostEventHandlerSkipsRequests()
        {
            var http    = new Mock <HttpContext>();
            var next    = new Mock <RequestDelegate>();
            var post    = new PostEventHandler(Context.Application, next.Object);
            var request = new Mock <HttpRequest>();

            http.Setup(x => x.Request).Returns(request.Object);
            request.Setup(x => x.Path).Returns(PostEventHandler.EventPrefix);
            request.Setup(x => x.Method).Returns("LALA");
            var websockets = new Mock <WebSocketManager>();

            http.Setup(x => x.WebSockets).Returns(websockets.Object);
            Assert.False(await post.ProcessRequest(http.Object));
        }