Пример #1
0
        public void SetUp()
        {
            files = new AssetFile[] {
                new AssetFile("something.js")
                {
                    FullPath = "something.js"
                },
                new AssetFile("something2.js")
                {
                    FullPath = "something2.js"
                },
                new AssetFile("something3.js")
                {
                    FullPath = "something3.js"
                },
                new AssetFile("something4.js")
                {
                    FullPath = "something4.js"
                },
            };

            thePlan            = new ContentPlan("a plan", files);
            theReadFileSource  = thePlan.GetAllSources().ElementAt(2);
            theTransformerNode = thePlan.ApplyTransform(theReadFileSource, typeof(StubTransformer));
        }
Пример #2
0
        public void constructor_sets_up_the_default_content_sources_for_each_file()
        {
            var files = new AssetFile[] {
                new AssetFile("something.js")
                {
                    FullPath = "something.js"
                },
                new AssetFile("something2.js")
                {
                    FullPath = "something2.js"
                },
                new AssetFile("something3.js")
                {
                    FullPath = "something3.js"
                },
                new AssetFile("something4.js")
                {
                    FullPath = "something4.js"
                },
            };

            var plan = new ContentPlan("a plan", files);

            plan.GetAllSources().ShouldHaveTheSameElementsAs(files.Select(x => new FileRead(x)));
        }
Пример #3
0
        public void find_for_file_initially()
        {
            var files = new AssetFile[] {
                new AssetFile("something.js")
                {
                    FullPath = "something.js"
                },
                new AssetFile("something2.js")
                {
                    FullPath = "something2.js"
                },
                new AssetFile("something3.js")
                {
                    FullPath = "something3.js"
                },
                new AssetFile("something4.js")
                {
                    FullPath = "something4.js"
                },
            };

            var plan = new ContentPlan("a plan", files);

            files.Each(f =>
            {
                plan.FindForFile(f).ShouldBeOfType <FileRead>().Files.Single().ShouldBeTheSameAs(f);
            });
        }
Пример #4
0
        public void InitialSourceForAssetFile_needs_to_throw_out_of_range_exception_if_there_is_no_full_path_for_the_asset_for_now()
        {
            var assetFile = new AssetFile("something.js");

            assetFile.FullPath.IsEmpty();


            Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() =>
            {
                ContentPlan.InitialSourceForAssetFile(assetFile);
            });
        }
Пример #5
0
        public void initial_source_for_asset_file_with_a_path_is_a_read_file_source()
        {
            var assetFile = new AssetFile("something.js")
            {
                FullPath = "something"
            };

            var source = ContentPlan.InitialSourceForAssetFile(assetFile)
                         .ShouldBeOfType <FileRead>();

            source.Files.Single().ShouldBeTheSameAs(assetFile);
        }
Пример #6
0
        public void use_full_name_if_there_is_a_package()
        {
            var path    = new AssetPath("pak1", "a.js", AssetFolder.scripts);
            var thePlan = new ContentPlan("something", new AssetFile[] { new AssetFile("a.js")
                                                                         {
                                                                             FullPath = "a.js"
                                                                         }, });

            MockFor <IContentPlanner>().Stub(x => x.BuildPlanFor(path.ToFullName()))
            .Return(thePlan);

            ClassUnderTest.SourceFor(path).ShouldBeTheSameAs(thePlan);
        }
Пример #7
0
        public void only_use_the_name_if_there_is_no_package()
        {
            var path    = new AssetPath("scripts/a.js");
            var thePlan = new ContentPlan("something", new AssetFile[] { new AssetFile("a.js")
                                                                         {
                                                                             FullPath = "a.js"
                                                                         }, });


            MockFor <IContentPlanner>().Stub(x => x.BuildPlanFor(path.Name))
            .Return(thePlan);

            ClassUnderTest.SourceFor(path).ShouldBeTheSameAs(thePlan);
        }
Пример #8
0
        public void try_it_against_a_3_deep_hierarchy()
        {
            var theFiles = new AssetFile[] {
                new AssetFile("a.js")
                {
                    FullPath = "a.js"
                },
                new AssetFile("b.js")
                {
                    FullPath = "b.js"
                },
                new AssetFile("c.js")
                {
                    FullPath = "c.js"
                },
                new AssetFile("d.js")
                {
                    FullPath = "d.js"
                },
            };

            var plan  = new ContentPlan("something", theFiles);
            var read0 = plan.GetAllSources().ElementAt(0);
            var read1 = plan.GetAllSources().ElementAt(1);
            var read2 = plan.GetAllSources().ElementAt(2);
            var read3 = plan.GetAllSources().ElementAt(3);

            var combo1 = plan.Combine(new IContentSource[] { read1, read2 });
            var combo2 = plan.Combine(new IContentSource[] { read0, combo1, read3 });


            var previewer = new ContentPlanPreviewer();

            plan.AcceptVisitor(previewer);

            previewer.WriteToDebug();

            var expected = new StringBuilder()
                           .AppendLine("Combination")
                           .AppendLine("  FileRead:a.js")
                           .AppendLine("  Combination")
                           .AppendLine("    FileRead:b.js")
                           .AppendLine("    FileRead:c.js")
                           .Append("  FileRead:d.js");

            previewer.ToFullDescription().ShouldEqual(expected);
        }
Пример #9
0
        public void AssertMatches(ContentPlan plan)
        {
            var previewer = new ContentPlanPreviewer();

            plan.AcceptVisitor(previewer);

            try
            {
                previewer.Descriptions.ShouldHaveTheSameElementsAs(_expectations);
            }
            catch (Exception)
            {
                new ContentExpectationWriter(_expectations, previewer.Descriptions.ToList()).Write();

                throw;
            }
        }
Пример #10
0
        public void caches_the_content_plan_from_the_planner()
        {
            var jsFile = new AssetFile("script.js")
            {
                FullPath = "something"
            };

            var thePlan = new ContentPlan("something", new AssetFile[] { jsFile });

            MockFor <IContentPlanner>().Expect(x => x.BuildPlanFor(thePlan.Name))
            .Return(thePlan)
            .Repeat.Once();

            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);
            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);
            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);
            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);
            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);
            ClassUnderTest.PlanFor(thePlan.Name).ShouldBeTheSameAs(thePlan);

            MockFor <IContentPlanner>().VerifyAllExpectations();
        }
Пример #11
0
        public void SetUp()
        {
            files = new AssetFile[] {
                new AssetFile("something.js")
                {
                    FullPath = "something.js"
                },
                new AssetFile("something2.js")
                {
                    FullPath = "something2.js"
                },
                new AssetFile("something3.js")
                {
                    FullPath = "something3.js"
                },
                new AssetFile("something4.js")
                {
                    FullPath = "something4.js"
                },
            };

            thePlan        = new ContentPlan("a plan", files);
            theCombination = thePlan.Combine(new[] { thePlan.GetAllSources().ElementAt(0), thePlan.GetAllSources().ElementAt(1) });
        }
Пример #12
0
        public void accept_a_visitor_simple()
        {
            var mocks = new MockRepository();

            var visitor = mocks.StrictMock <IContentPlanVisitor>();


            theFiles = new AssetFile[] {
                new AssetFile("a.js")
                {
                    FullPath = "a.js"
                },
                new AssetFile("b.js")
                {
                    FullPath = "b.js"
                },
                new AssetFile("c.js")
                {
                    FullPath = "c.js"
                },
                new AssetFile("d.js")
                {
                    FullPath = "d.js"
                },
            };

            var plan  = new ContentPlan("something", theFiles);
            var read0 = plan.GetAllSources().ElementAt(0);
            var read1 = plan.GetAllSources().ElementAt(1);
            var read2 = plan.GetAllSources().ElementAt(2);
            var read3 = plan.GetAllSources().ElementAt(3);

            var combo1 = plan.Combine(new IContentSource[] { read1, read2 });
            var combo2 = plan.Combine(new IContentSource[] { read0, combo1, read3 });

            using (mocks.Ordered())
            {
                visitor.Expect(x => x.Push(combo2));

                visitor.Expect(x => x.Push(read0));
                visitor.Expect(x => x.Pop());

                visitor.Expect(x => x.Push(combo1));

                visitor.Expect(x => x.Push(read1));
                visitor.Expect(x => x.Pop());

                visitor.Expect(x => x.Push(read2));
                visitor.Expect(x => x.Pop());

                visitor.Expect(x => x.Pop());


                visitor.Expect(x => x.Push(read3));
                visitor.Expect(x => x.Pop());

                visitor.Expect(x => x.Pop());
            }

            mocks.ReplayAll();

            plan.AcceptVisitor(visitor);


            mocks.VerifyAll();
        }
Пример #13
0
 public ContentPlanShouldBeExpression(ContentPlan plan)
 {
     _plan = plan;
 }