public void ValidateNullSettingsTest() { BiscuitMakerSettings settings = null; Action action = () => BiscuitMakerSettingsValidator.ValidateSettings(settings, true); action.Should().Throw <ArgumentException>().WithMessage("Settings can not be null"); }
/// <summary> /// The create. /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="BiscuitMakerObject"/>. /// </returns> public static BiscuitMakerObject Create(BiscuitMakerSettings settings = null) { var settingsAreValid = BiscuitMakerSettingsValidator.ValidateSettings(settings, false); if (!settingsAreValid) { return(null); } var components = new List <IBiscuitComponent>(); var switchComponent = Switch.Create(); components.Add(switchComponent); var switcher = new Switcher(); components.Add(switcher); if (settings != null) { var conveyor = Conveyor.Create(count: settings.ConveyorSize); components.Add(conveyor); } if (settings != null) { var oven = Oven.Create(settings.RoomTemperature); components.Add(oven); } var bucket = BiscuitBucket.Create(); components.Add(bucket); var motor = new Motor(); components.Add(motor); var timeRunner = new TimeRunner(); components.Add(timeRunner); var biscuitMaker = BiscuitMakerObject.Create(components, settings); biscuitMaker.FirstSwitcher.RaiseSwitchOn += OvenManager.HandleSwitchOn; biscuitMaker.FirstTimeRunner.RaiseClockTick += OvenManager.HandleClockTick; biscuitMaker.FirstTimeRunner.RaiseClockTick += biscuitMaker.FirstMotor.HandleClockTick; biscuitMaker.FirstMotor.RaisePulse += ConveyorManager.HandleMotorPulse; return(biscuitMaker); }
public void ValidateInvalidOvenTemperatureSettingsTest() { BiscuitMakerSettings settings = new BiscuitMakerSettings { ConveyorSize = 6, ExtruderIndex = 0, OvenCoolingRate = 10, OvenHeatingRate = 10, OvenIndex = 3, OvenMaxTemp = 220, OvenMinTemp = 240, OvenSize = 2, StamperIndex = 1, }; Action action = () => BiscuitMakerSettingsValidator.ValidateSettings(settings, true); action.Should().Throw <ArgumentException>().WithMessage("Invalid oven temperature settings"); }
public void ValidateValidSettingsTest() { var settings = new BiscuitMakerSettings { ConveyorSize = 6, ExtruderIndex = 0, OvenCoolingRate = 10, OvenHeatingRate = 10, OvenIndex = 3, OvenMaxTemp = 240, OvenMinTemp = 220, OvenSize = 2, StamperIndex = 1, }; Action action = () => BiscuitMakerSettingsValidator.ValidateSettings(settings); action.Should().NotThrow(); }