Exemplo n.º 1
0
        public void RequestPathParts_Splits_RequestPath_Into_Chunks(string[] expected, string requestPath)
        {
            var actual = OwinPath.RequestPathParts(requestPath);

            if (expected == null)
            {
                Assert.IsNull(actual);
            }
            else
            {
                Assert.IsTrue(expected.SequenceEqual(actual));
            }
        }
Exemplo n.º 2
0
        public void RequestPathParts_Rebuilds_Cache_If_Path_Changes()
        {
            var environment = new MockOwinEnvironment();

            environment.RequestPath = "/a";

            var pathParts1 = OwinPath.RequestPathParts(environment.Environment, createAndUseCachedResult: true);

            environment.RequestPath = "/b";
            var pathParts2 = OwinPath.RequestPathParts(environment.Environment, createAndUseCachedResult: true);

            Assert.AreNotSame(pathParts1, pathParts2);
            Assert.AreEqual(1, pathParts2.Length);
            Assert.AreEqual("b", pathParts2[0]);
        }
Exemplo n.º 3
0
        public void RequestPathParts_Can_Cache_Result_In_Environment(bool createCacheEntry)
        {
            var environment = new MockOwinEnvironment();

            environment.RequestPath = "/a";

            var actual = OwinPath.RequestPathParts(environment.Environment, createAndUseCachedResult: createCacheEntry);

            Assert.AreEqual(1, actual.Length);
            Assert.AreEqual("a", actual[0]);

            var cacheEntry = environment.Environment[CustomEnvironmentKey.RequestPathParts] as IList <string>;

            if (createCacheEntry)
            {
                Assert.IsTrue(actual.SequenceEqual(cacheEntry));
            }
            else
            {
                Assert.IsNull(cacheEntry);
            }
        }
Exemplo n.º 4
0
        public void RequestPathParts_Extracts_RequestPath_From_Environment_And_Splits_Into_Chunks(string[] expected, string requestPath)
        {
            foreach (var useCache in new bool[] { true, false })
            {
                var environment = new MockOwinEnvironment();
                if (requestPath != null)
                {
                    environment.RequestPath = requestPath;
                }

                var actual = OwinPath.RequestPathParts(environment.Environment, useCache);

                if (expected == null)
                {
                    Assert.IsNull(actual);
                }
                else
                {
                    Assert.IsTrue(expected.SequenceEqual(actual));
                }
            }
        }