public static void Run() { Console.WriteLine($"{Environment.NewLine}*** ITERATOR PATTERN ***{Environment.NewLine}"); BikeProductionLine productionLine = new BikeProductionLine(new Bike { ProductionNumber = 1 }); productionLine.Add(new Bike { ProductionNumber = 2 }); productionLine.Add(new Bike { ProductionNumber = 3 }); productionLine.Add(new Bike { ProductionNumber = 4 }); BikeIterator iterator = productionLine.CreateIterator(); while (!iterator.IsFinished) { iterator.CurrentBike.Build(); iterator.Next(); } }
public static void Run() { Console.WriteLine($"{Environment.NewLine}*** PROTOTYPE PATTERN ***{Environment.NewLine}"); Bike bike = new Bike { ModelName = "Rocket", ProductionNumber = 1 }; BikeProductionLine line = new BikeProductionLine(bike, 10); line.Run(); }
public void BikeProductionLine_Run_BuildsCorrectNumberOfBikes() { // Arrange int numberOfBikesToMake = 100; Mock <Bike> mockBike = new Mock <Bike>(); BikeProductionLine line = new BikeProductionLine(mockBike.Object, numberOfBikesToMake); mockBike.Setup(m => m.Clone()).Returns(mockBike.Object); // Act line.Run(); // Assert mockBike.Verify(m => m.Clone(), Times.Exactly(numberOfBikesToMake)); }
public void BikeProductionLine_CreateIterator_IteratorsAcrossAllBikesInPRoductionLine() { // Arrange Mock <Bike> mockBike = new Mock <Bike>(); BikeProductionLine line = new BikeProductionLine(mockBike.Object); BikeIterator iterator = line.CreateIterator(); // Act while (!iterator.IsFinished) { iterator.CurrentBike.Build(); iterator.Next(); } // Assert mockBike.Verify(m => m.Build(), Times.Once); }