Пример #1
0
        public void when_origin_is_host_prefix_is_emtpy()
        {
            var item = new Template("", "", FubuSparkConstants.HostOrigin);

            ClassUnderTest.Apply(item);
            item.ViewPath.ShouldBeEmpty();
        }
Пример #2
0
        protected override void beforeEach()
        {
            ClassUnderTest.Global("g");
            ClassUnderTest.Dependency("a", "b");

            ClassUnderTest.Apply(MockFor <IPackageLog>(), MockFor <ISharingRegistration>());
        }
Пример #3
0
        public void when_origin_is_not_host_prefix_is_not_emtpy()
        {
            var item = new Template("", "", "Foo");

            ClassUnderTest.Apply(item);
            item.ViewPath.ShouldNotBeEmpty();
        }
Пример #4
0
        public void should_return_single_view_token_matched_on_policy_criteria()
        {
            _descriptor.Templates.Add("Projects\\Dashboard.spark");
            _descriptor.Templates.Add("Shared\\Application.spark");

            var descriptor2 = newDescriptor();

            descriptor2.Templates.Add("Projects\\StoryMap.spark");
            descriptor2.Templates.Add("Shared\\Application.spark");
            _token.Descriptors.Add(descriptor2);

            var descriptor3 = newDescriptor();

            descriptor3.Templates.Add("Projects.spark");
            descriptor3.Templates.Add("Shared\\Application.spark");
            _token.Descriptors.Add(descriptor3);


            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.HasMatchFor(_call))
            .Return(true);

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewLocator(_call))
            .Return("");

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewName(_call))
            .Return("Projects");

            ClassUnderTest
            .Apply(_call, _views)
            .FirstOrDefault()
            .ShouldNotBeNull();
        }
        protected override void beforeEach()
        {
            _graph = new AssetGraph();

            _assetsForSetA = new[] { "a-1.js", "a-2.js" };
            _assetsForSetB = new[] { "b-1.css", "b-2.css" };

            _assetsForSetC = new[] { "c-1.js", "c-2.js", "c-3.css", "c-4.css" };

            _assetsForSetA.Each(x => _graph.AddToSet("setA", x));
            _assetsForSetB.Each(x => _graph.AddToSet("setB", x));
            _assetsForSetC.Each(x => _graph.AddToSet("setC", x));

            _graph.CompileDependencies(null);

            MockFor <IAssetDependencyFinder>()
            .Stub(x => x.CompileDependenciesAndOrder(new[] { "setA" }))
            .Return(_assetsForSetA);

            MockFor <IAssetDependencyFinder>()
            .Stub(x => x.CompileDependenciesAndOrder(new[] { "setB" }))
            .Return(_assetsForSetB);

            MockFor <IAssetDependencyFinder>()
            .Stub(x => x.CompileDependenciesAndOrder(new[] { "setC" }))
            .Return(_assetsForSetC);

            ClassUnderTest.Apply(null, null, _graph);
        }
        private void registerBindersAndPolicies()
        {
            ClassUnderTest.AddBinder(_binder1);
            ClassUnderTest.AddBinder(_binder2);

            ClassUnderTest.Apply(_policy1);
            ClassUnderTest.Apply(_policy2);
        }
Пример #7
0
        public void should_return_empty_collection_when_action_call_returns_a_fubu_continuation()
        {
            var call = ActionCall.For <SampleEndpoint>(e => e.Post());

            ClassUnderTest
            .Apply(call, _views)
            .ShouldHaveCount(0);
        }
Пример #8
0
        public void it_matches_when_viewpath_is_empty()
        {
            var item = new Template("", "", "Foo");

            ClassUnderTest.Matches(item).ShouldBeTrue();
            ClassUnderTest.Apply(item);
            ClassUnderTest.Matches(item).ShouldBeFalse();
        }
Пример #9
0
        public void should_return_empty_collection_when_resolver_has_no_matching_policies()
        {
            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.HasMatchFor(_call))
            .Return(false);

            ClassUnderTest
            .Apply(_call, _views)
            .ShouldHaveCount(0);
        }
Пример #10
0
        public void namespace_of_files_in_root_is_set_correctly()
        {
            var path = Path.Combine(_root, "home.spark");
            var item = new Template(path, _root, "");

            item.Descriptor = new ViewDescriptor(item)
            {
                ViewModel = typeof(FooViewModel)
            };

            ClassUnderTest.Apply(item);
            item.Descriptor.As <ViewDescriptor>().Namespace.ShouldEqual("FubuMVC.Spark.Tests");
        }
Пример #11
0
        public void the_items_of_the_same_origin_have_the_same_prefix()
        {
            var baz1 = new Template("", "", "Baz");
            var baz2 = new Template("", "", "Baz");
            var bar1 = new Template("", "", "Bar");
            var bar2 = new Template("", "", "Bar");

            new[] { baz1, baz2, bar1, bar2 }.Each(x => ClassUnderTest.Apply(x));

            baz1.ViewPath.ShouldEqual(baz2.ViewPath);
            bar1.ViewPath.ShouldEqual(bar2.ViewPath);
            baz1.ViewPath.ShouldNotEqual(bar1.ViewPath);
        }
Пример #12
0
        public void should_return_empty_collection_when_no_desciptors_are_matched()
        {
            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.HasMatchFor(_call))
            .Return(true);

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewLocator(_call))
            .Return("");

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewName(_call))
            .Return("");

            ClassUnderTest
            .Apply(_call, _views)
            .ShouldHaveCount(0);
        }
Пример #13
0
        public void apply_register_the_policies_and_use_them_when_building_items()
        {
            var invoked1 = false;
            var invoked2 = false;

            var policy = new FakeTemplatePolicy();

            policy.Action += x => invoked1 = true;

            ClassUnderTest.Apply(policy);
            ClassUnderTest.Apply <FakeTemplatePolicy>(p => p.Action += x => invoked2 = true);
            ClassUnderTest.Apply <OtherTemplatePolicy>();

            ClassUnderTest.Compose(_templateRegistry);

            invoked1.ShouldBeTrue();
            invoked2.ShouldBeTrue();
            OtherTemplatePolicy.Invoked.ShouldBeTrue();
        }
Пример #14
0
        public void should_return_single_view_token_when_desciptor_is_matched()
        {
            _descriptor.Templates.Add("TestFolder\\Sample.spark");

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.HasMatchFor(_call))
            .Return(true);

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewLocator(_call))
            .Return("TestFolder");

            MockFor <ISparkPolicyResolver>()
            .Expect(resolver => resolver.ResolveViewName(_call))
            .Return("Sample");

            var token = ClassUnderTest
                        .Apply(_call, _views)
                        .FirstOrDefault();

            token.ShouldNotBeNull();
            token.Name.ShouldEqual("Sample");
        }
 public void namespace_of_files_that_are_located_in_nested_directory_is_set_correctly()
 {
     _template.FilePath = Path.Combine(Root, "a", "b", "c", "home.spark");
     ClassUnderTest.Apply(_template);
     _template.Descriptor.As <SparkDescriptor>().Namespace.ShouldEqual("FubuMVC.Spark.Tests.a.b.c");
 }
 public void when_origin_is_not_host_view_path_is_prefixed()
 {
     _template.Origin = "Foo";
     ClassUnderTest.Apply(_template);
     _template.ViewPath.ShouldEqual(FileSystem.Combine("_" + _template.Origin, "view.spark"));
 }
 public void when_origin_is_host_viewpath_is_not_prefixed()
 {
     ClassUnderTest.Apply(_template);
     _template.ViewPath.ShouldEqual("view.spark");
 }
 public void namespace_of_files_in_root_is_set_correctly()
 {
     ClassUnderTest.Apply(_template);
     _template.Descriptor.As <SparkDescriptor>().Namespace.ShouldEqual("FubuMVC.Spark.Tests");
 }