public void build_delegates()
        {
            var builder = new ConditionalTagBuilderPolicy<FakeSubject>(x => x.Level > 10, x => new HtmlTag("div").Text(x.Name));

            var subject = new FakeSubject
            {
                Name = "Max"
            };
            builder.BuilderFor(subject).Build(subject)
                .ToString()
                .ShouldEqual("<div>Max</div>");
        }
Esempio n. 2
0
 public bool Equals(FakeSubject other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Name, Name) && other.Level == Level);
 }
        public void build_delegates()
        {
            var builder = new ConditionalTagBuilderPolicy <FakeSubject>(x => x.Level > 10, x => new HtmlTag("div").Text(x.Name));

            var subject = new FakeSubject
            {
                Name = "Max"
            };

            builder.BuilderFor(subject).Build(subject)
            .ToString()
            .ShouldEqual("<div>Max</div>");
        }
        public void modify_delegates()
        {
            var builder = new LambdaTagModifier(x => ((FakeSubject)x).Level > 10, x => x.CurrentTag.AddClass("foo"));

            var subject = new FakeSubject
                              {
                                  Name = "Max"
                              };
            subject.ReplaceTag(new HtmlTag("div"));

            builder.Modify(subject);

            subject.CurrentTag.HasClass("foo").ShouldBeTrue();
        }
        public void modify_delegates()
        {
            var builder = new LambdaTagModifier(x => ((FakeSubject)x).Level > 10, x => x.CurrentTag.AddClass("foo"));

            var subject = new FakeSubject
            {
                Name = "Max"
            };

            subject.ReplaceTag(new HtmlTag("div"));

            builder.Modify(subject);

            subject.CurrentTag.HasClass("foo").ShouldBeTrue();
        }
        protected override void beforeEach()
        {
            theActivators = Services.CreateMockArrayFor <ITagRequestActivator>(5);

            theActivators[0].Stub(x => x.Matches(typeof(FakeSubject))).Return(true);
            theActivators[1].Stub(x => x.Matches(typeof(FakeSubject))).Return(false);
            theActivators[2].Stub(x => x.Matches(typeof(FakeSubject))).Return(true);
            theActivators[3].Stub(x => x.Matches(typeof(FakeSubject))).Return(false);
            theActivators[4].Stub(x => x.Matches(typeof(FakeSubject))).Return(true);

            theSubject = new FakeSubject()
            {
                Name  = "HerpDerp",
                Level = 99
            };
        }
Esempio n. 7
0
        public void builds_default_if_no_category_or_profile_is_specified()
        {
            theLibrary.Always.Build(x => new HtmlTag("div").Text(((FakeSubject)x).Name));
            theLibrary.Category("a").Always.Build(x => new HtmlTag("a").Text(((FakeSubject)x).Name));
            theLibrary.Category("b").Always.Build(x => new HtmlTag("b").Text(((FakeSubject)x).Name));

            theLibrary.ForProfile("profile1").Always.Build(x => new HtmlTag("p").Text(((FakeSubject)x).Name));
            theLibrary.Category("a").ForProfile("a-1").Always.Modify(x => x.CurrentTag.AddClass("a-1"));

            var subject = new FakeSubject { Name = "Lindsey" };

            build(subject).ToString().ShouldEqual("<div>Lindsey</div>");
            build(subject, category:"a").ToString().ShouldEqual("<a>Lindsey</a>");
            build(subject, category:"a", profile:"a-1").ToString().ShouldEqual("<a class=\"a-1\">Lindsey</a>");
            build(subject, category:"b").ToString().ShouldEqual("<b>Lindsey</b>");
            build(subject, profile:"profile1").ToString().ShouldEqual("<p>Lindsey</p>");
        }
Esempio n. 8
0
        public void equals()
        {
            var subject1 = new FakeSubject{
                Name = "Jeremy",
                Level = 20
            };

            var subject2 = new FakeSubject{
                Name = "Different",
                Level = int.MaxValue
            };

            subject1.ShouldNotEqual(subject2);

            new TagSubject<FakeSubject>("a", subject1).ShouldEqual(new TagSubject<FakeSubject>("a", subject1));
            new TagSubject<FakeSubject>("a", subject2).ShouldEqual(new TagSubject<FakeSubject>("a", subject2));
            new TagSubject<FakeSubject>("a", subject1).ShouldNotEqual(new TagSubject<FakeSubject>("a", subject2));
            new TagSubject<FakeSubject>("a", subject2).ShouldNotEqual(new TagSubject<FakeSubject>("b", subject2));
        }
Esempio n. 9
0
        public void builds_default_if_no_category_or_profile_is_specified()
        {
            theLibrary.Always.Build(x => new HtmlTag("div").Text(x.Name));
            theLibrary.Category("a").Always.Build(x => new HtmlTag("a").Text(x.Name));
            theLibrary.Category("b").Always.Build(x => new HtmlTag("b").Text(x.Name));

            theLibrary.ForProfile("profile1").Always.Build(x => new HtmlTag("p").Text(x.Name));
            theLibrary.Category("a").ForProfile("a-1").Always.Modify(x => x.CurrentTag.AddClass("a-1"));

            var subject = new FakeSubject {
                Name = "Lindsey"
            };

            build(subject).ToString().ShouldEqual("<div>Lindsey</div>");
            build(subject, category: "a").ToString().ShouldEqual("<a>Lindsey</a>");
            build(subject, category: "a", profile: "a-1").ToString().ShouldEqual("<a class=\"a-1\">Lindsey</a>");
            build(subject, category: "b").ToString().ShouldEqual("<b>Lindsey</b>");
            build(subject, profile: "profile1").ToString().ShouldEqual("<p>Lindsey</p>");
        }
Esempio n. 10
0
        public void equals()
        {
            var subject1 = new FakeSubject {
                Name  = "Jeremy",
                Level = 20
            };

            var subject2 = new FakeSubject {
                Name  = "Different",
                Level = int.MaxValue
            };

            subject1.ShouldNotEqual(subject2);

            new TagSubject("a", subject1).ShouldEqual(new TagSubject("a", subject1));
            new TagSubject("a", subject2).ShouldEqual(new TagSubject("a", subject2));
            new TagSubject("a", subject1).ShouldNotEqual(new TagSubject("a", subject2));
            new TagSubject("a", subject2).ShouldNotEqual(new TagSubject("b", subject2));
        }
Esempio n. 11
0
        public void get_hashcode()
        {
            var subject1 = new FakeSubject
            {
                Name  = "Jeremy",
                Level = 20
            };

            var subject2 = new FakeSubject
            {
                Name  = "Different",
                Level = int.MaxValue
            };

            subject1.ShouldNotEqual(subject2);

            new TagSubject <FakeSubject>("a", subject1).GetHashCode().ShouldEqual(new TagSubject <FakeSubject>("a", subject1).GetHashCode());
            new TagSubject <FakeSubject>("a", subject2).GetHashCode().ShouldEqual(new TagSubject <FakeSubject>("a", subject2).GetHashCode());
            new TagSubject <FakeSubject>("a", subject1).GetHashCode().ShouldNotEqual(new TagSubject <FakeSubject>("a", subject2).GetHashCode());
            new TagSubject <FakeSubject>("a", subject2).GetHashCode().ShouldNotEqual(new TagSubject <FakeSubject>("b", subject2).GetHashCode());
        }
Esempio n. 12
0
        public void get_hashcode()
        {
            var subject1 = new FakeSubject
            {
                Name = "Jeremy",
                Level = 20
            };

            var subject2 = new FakeSubject
            {
                Name = "Different",
                Level = int.MaxValue
            };

            subject1.ShouldNotEqual(subject2);

            new TagSubject("a", subject1).GetHashCode().ShouldEqual(new TagSubject("a", subject1).GetHashCode());
            new TagSubject("a", subject2).GetHashCode().ShouldEqual(new TagSubject("a", subject2).GetHashCode());
            new TagSubject("a", subject1).GetHashCode().ShouldNotEqual(new TagSubject("a", subject2).GetHashCode());
            new TagSubject("a", subject2).GetHashCode().ShouldNotEqual(new TagSubject("b", subject2).GetHashCode());
        }
Esempio n. 13
0
        public void tag_plan_is_memoized_by_profile_and_subject()
        {
            var subject1 = new FakeSubject {
                Name = "Jeremy", Level = 10
            };
            var subject2 = new FakeSubject {
                Name = "Jeremy", Level = 10
            };

            subject1.ShouldEqual(subject2);

            theCategory.Always.Build(x => new HtmlTag("div"));
            theCategory.ForProfile("a").Always.Build(x => new HtmlTag("a"));
            theCategory.ForProfile("b").Always.Build(x => new HtmlTag("b"));



            theCategory.PlanFor(subject1).ShouldBeSameAs(theCategory.PlanFor(subject2));
            theCategory.PlanFor(subject1, "a").ShouldBeSameAs(theCategory.PlanFor(subject2, "a"));
            theCategory.PlanFor(subject1, "b").ShouldBeSameAs(theCategory.PlanFor(subject2, "b"));

            theCategory.PlanFor(subject1, "a").ShouldNotBeSameAs(theCategory.PlanFor(subject2, "b"));
            theCategory.PlanFor(subject1, "b").ShouldNotBeSameAs(theCategory.PlanFor(subject2, "a"));
        }
Esempio n. 14
0
 private HtmlTag build(FakeSubject subject, string category = null,string profile = null)
 {
     var plan = theLibrary.PlanFor(subject, profile:profile, category:category);
     return plan.Build(subject);
 }
Esempio n. 15
0
        private HtmlTag build(FakeSubject subject, string category = null, string profile = null)
        {
            var plan = theLibrary.PlanFor(subject, profile: profile, category: category);

            return(plan.Build(subject));
        }
Esempio n. 16
0
 private HtmlTag build(FakeSubject subject, string profile = null)
 {
     var plan = theCategory.PlanFor(subject, profile);
     return plan.Build(subject);
 }
Esempio n. 17
0
 public bool Matches(FakeSubject subject)
 {
     return subject.Level == _level;
 }
Esempio n. 18
0
 public bool Equals(FakeSubject other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Name, Name) && other.Level == Level;
 }
Esempio n. 19
0
        public void tag_plan_is_memoized_by_profile_and_subject()
        {
            var subject1 = new FakeSubject { Name = "Jeremy", Level = 10 };
            var subject2 = new FakeSubject { Name = "Jeremy", Level = 10 };

            subject1.ShouldEqual(subject2);

            theCategory.Always.Build(x => new HtmlTag("div"));
            theCategory.ForProfile("a").Always.Build(x => new HtmlTag("a"));
            theCategory.ForProfile("b").Always.Build(x => new HtmlTag("b"));



            theCategory.PlanFor(subject1).ShouldBeSameAs(theCategory.PlanFor(subject2));
            theCategory.PlanFor(subject1, "a").ShouldBeSameAs(theCategory.PlanFor(subject2, "a"));
            theCategory.PlanFor(subject1, "b").ShouldBeSameAs(theCategory.PlanFor(subject2, "b"));

            theCategory.PlanFor(subject1, "a").ShouldNotBeSameAs(theCategory.PlanFor(subject2, "b"));
            theCategory.PlanFor(subject1, "b").ShouldNotBeSameAs(theCategory.PlanFor(subject2, "a"));
        }
Esempio n. 20
0
 public bool Matches(FakeSubject subject)
 {
     return(subject.Level == _level);
 }
Esempio n. 21
0
        private HtmlTag build(FakeSubject subject, string profile = null)
        {
            var plan = theCategory.PlanFor(subject, profile);

            return(plan.Build(subject));
        }