Ejemplo n.º 1
0
        public void MountainBike_BuildBike_CallsInstructions()
        {
            // Arrange
            IBike bike = new MountainBike();
            Mock <IInstruction> inst = new Mock <IInstruction>();

            // Act
            bike.BuildBike();
            bike.ChangeInstructions(new List <IInstruction> {
                inst.Object
            });
            bike.BuildBike();

            // Assert
            inst.Verify(i => i.AddComponent(), Times.Once);
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            Console.WriteLine($"{Environment.NewLine}*** STRATERGY PATTERN ***{Environment.NewLine}");

            IBike mountainBike = new MountainBike();

            // Build with default instructions
            mountainBike.BuildBike();

            mountainBike.ChangeInstructions(new List <IInstruction>
            {
                new FrameInstruction(),
                new BrakesInstruction(),
                new LightsInstruction(),
                new WheelsInstruction(),
                new ShocksInstruction()
            });

            // Build with new instructions.
            mountainBike.BuildBike();
        }