private static void Main() { SimpleBuilder.Create().Id(1).Name("Riku").Age(17).Build().Show(); SimpleBuilder.Create().Id(2).Build().Show(); // (no name, no id) SimpleBuilder.Create().Id(3).Name("Kimi").Name("Maria").Build().Show(); // (no id, two names) Builder.Create().Id(4).Name("Aki").Build().Show(); Builder.Create().Name("Anna").Id(5).Build().Show(); Builder.Create().Name("Mika").Age(24).Id(6).Build().Show(); // Builder.Create().Id(7).Name("Masa").Name("Jarkko").Build(); // type error. (two names) // Builder.Create().Id(8).Build(); // type error. (no name) }
public void Build_ReturnsANewInstanceOfTheTargetClass() { //---------------Set up test pack------------------- var builder = SimpleBuilder.Create(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var simple1 = builder.Build(); var simple2 = builder.Build(); //---------------Test Result ----------------------- Expect(simple1).Not.To.Be.Null(); Expect(simple2).Not.To.Be.Null(); Expect(simple1).To.Be.An.Instance.Of <SimpleClass>(); Expect(simple2).To.Be.An.Instance.Of <SimpleClass>(); Expect(simple1).Not.To.Be(simple2); }
public void Create_ReturnsANewInstanceOfTheBuilder() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var b1 = SimpleBuilder.Create(); var b2 = SimpleBuilder.Create(); //---------------Test Result ----------------------- Expect(b1).Not.To.Be.Null(); Expect(b2).Not.To.Be.Null(); Expect(b1).To.Be.An.Instance.Of <SimpleBuilder>(); Expect(b2).To.Be.An.Instance.Of <SimpleBuilder>(); Expect(b1).Not.To.Be(b2); }