static void Main(string[] args) { // Create director and builders Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // Construct two products director.Construct(b1); Product p1 = b1.GetResult(); p1.Show(); director.Construct(b2); Product p2 = b2.GetResult(); p2.Show(); }
public void Test() { var director = new Director(); Builder builder = null; builder = new Builder1(); director.Construct(builder); var result1 = builder.GetResult(); builder = new Builder2(); director.Construct(builder); var result2 = builder.GetResult(); Assert.AreEqual("Part A", result1.PartOne); Assert.AreEqual("Part B", result1.PartTwo); Assert.AreEqual("Part X", result2.PartOne); Assert.AreEqual("Part Y", result2.PartTwo); }