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 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 }; }
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>"); }
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)); }
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>"); }
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)); }
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()); }
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()); }
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")); }
private HtmlTag build(FakeSubject subject, string category = null,string profile = null) { var plan = theLibrary.PlanFor(subject, profile:profile, category:category); return plan.Build(subject); }
private HtmlTag build(FakeSubject subject, string category = null, string profile = null) { var plan = theLibrary.PlanFor(subject, profile: profile, category: category); return(plan.Build(subject)); }
private HtmlTag build(FakeSubject subject, string profile = null) { var plan = theCategory.PlanFor(subject, profile); return plan.Build(subject); }
public bool Matches(FakeSubject subject) { return subject.Level == _level; }
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 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")); }
public bool Matches(FakeSubject subject) { return(subject.Level == _level); }
private HtmlTag build(FakeSubject subject, string profile = null) { var plan = theCategory.PlanFor(subject, profile); return(plan.Build(subject)); }