Exemplo n.º 1
0
        public void Exists_NoNodes_ReturnsFalse()
        {
            using (new ObjectFactoryContainerRegion())
            {
                ObjectFactory.Container.RegisterType<IResourceResolverStrategy, ResourceResolverStrategy>(new ContainerControlledLifetimeManager());
                ObjectFactory.Resolve<IResourceResolverStrategy>().SetFirst(null);

                var resolver = new ResourceResolver();

                var result = resolver.Exists(new PathDefinition(), "~/Test");
                Assert.IsFalse(result, "Resolver returned true for Exists when for all nodes Exists is false.");
            }
        }
Exemplo n.º 2
0
        public void Exists_SecondNodeExists_ReturnsTrue()
        {
            using (new ObjectFactoryContainerRegion())
            {
                ObjectFactory.Container.RegisterType<IResourceResolverStrategy, ResourceResolverStrategy>(new ContainerControlledLifetimeManager());

                var firstNode = new DummyResourceResolverNode();
                firstNode.CurrentExistsMock = (pathDefinition, virtualPath) => false;

                var secondNode = new DummyResourceResolverNode();
                secondNode.CurrentExistsMock = (pathDefinition, virtualPath) => true;

                ObjectFactory.Resolve<IResourceResolverStrategy>()
                    .SetFirst(firstNode)
                    .SetNext(secondNode);

                var resolver = new ResourceResolver();
                var result = resolver.Exists(new PathDefinition(), "~/Test");

                Assert.IsTrue(result, "Resolver returned false for Exists while there is one node for which the resource exits.");
            }
        }