Exemplo n.º 1
0
 public void SetUpNewNextHandler()
 {
     TextHandler target = new TextHandler();
     BinaryHandler helpHandler = new BinaryHandler();
     target.SetNext(helpHandler);
     Assert.IsTrue(target.NextHandler == helpHandler);
 }
Exemplo n.º 2
0
        public void TextHandleTest()
        {
            TextHandler target = new TextHandler();
            Request req = new Request();
            req.HttpPath = "/index.html";

            string testFilePath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd(new[] {'\\'}) + "\\" +
                                  Configurator.Instance.RelativeWwwPath.TrimEnd(new[] {'\\'}) + "\\index.html";

            WriteTestFile(testFilePath);

            string text = System.IO.File.ReadAllText(testFilePath);
            byte[] bytes = Encoding.ASCII.GetBytes(text);

            //VK: commented, because exception was thrown?
            //Assert.IsTrue(target.Handle(req).Data.SequenceEqual(bytes));
        }
Exemplo n.º 3
0
 public void NextHandlerIsNullOnCreation()
 {
     TextHandler target = new TextHandler();
     Assert.IsNull(target.NextHandler);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Sends formed request object to the handlers
        /// </summary>
        /// <param name="request">
        /// </param>
        /// <returns>
        /// Responce
        /// </returns>
        private Response HandleRequest(Request request)
        {
            // create Handlers
            var handler1 = new SessionHandler();
            var handler2 = new DirectoryHandler();
            var handler3 = new AdminHandler();
            var handler4 = new TextHandler();
            var handler5 = new BinaryHandler();
            var handler6 = new ErrorHandler();

            // set Handler sequence of execution
            handler1.SetNext(handler2);
            handler2.SetNext(handler3);
            handler3.SetNext(handler4);
            handler4.SetNext(handler5);
            handler5.SetNext(handler6);

            // handle request
            return handler1.Handle(request);
        }