private void builderToolStripMenuItem_Click(object sender, EventArgs e) { UpdateOutput("A machine instance is created and a builder is passed to it, the resulting object returned depends on the builder used."); SandwichMachine sandwichMachine = new SandwichMachine(); Sandwich sandwich; sandwich = sandwichMachine.CreateSandwich(new MeatBallSandwichBuilder()); UpdateOutput("Sandwich 1: " + sandwich.ToString()); sandwich = sandwichMachine.CreateSandwich(new TurkeySandwichBuilder()); UpdateOutput("Sandwich 2: " + sandwich.ToString()); UpdateOutput(""); }
public void MeatballSandwichMachineTest() { SandwichMachine machine = new SandwichMachine(); Sandwich sandwich = machine.CreateSandwich(new MeatBallSandwichBuilder()); Assert.AreEqual(String.Format("{0} with {1} on {2} bread", "Meatballs", "Tomato Sauce", "Italian"), sandwich.ToString()); }
public void TurkeySandwichMachineTest() { SandwichMachine machine = new SandwichMachine(); Sandwich sandwich = machine.CreateSandwich(new TurkeySandwichBuilder()); Assert.AreEqual(String.Format("{0} with {1} on {2} bread", "Sliced Turkey", "Mayonaise", "White"), sandwich.ToString()); }