Beispiel #1
0
 public HotWeatherTests()
 {
     _writerMock     = Substitute.For <IWriter>();
     _dressValidator = Substitute.For <IDressValidator>();
     _hotWeather     = new HotWeatherDressing(_writerMock, _dressValidator);
     _dressValidator.isValid(Dress.PantsOn).ReturnsForAnyArgs(true);
 }
 public ColdWeatherTests()
 {
     _writerMock     = Substitute.For <IWriter>();
     _dressValidator = Substitute.For <IDressValidator>();
     _coldWeather    = new ColdWeatherDressing(_writerMock, _dressValidator);
     _dressValidator.isValid(Dress.Pajamas_Off).ReturnsForAnyArgs(true);
 }
        public void GivenTheWeatherIs(WeatherType weather)
        {
            dressed = new List <string>();
            Console.WriteLine(dressed.ToArray());
            switch (weather)
            {
            case WeatherType.HOT:
                _rulesEngine.ClearRules();
                _hotWeatherRules = new HotWeatherRules(_rulesEngine);
                _hotWeatherRules.ConfigureRules();
                _weatherType = new HotWeatherDressing(_writerMock, _dressValidator);
                break;

            case WeatherType.COLD:
                _rulesEngine.ClearRules();
                _coldWeatherRules = new ColdWeatherRules(_rulesEngine);
                _coldWeatherRules.ConfigureRules();
                _weatherType = new ColdWeatherDressing(_writerMock, _dressValidator);
                break;

            default:
                _weatherType = null;
                break;
            }

            ScenarioContext.Current.Add("WeatherType", _weatherType);
        }
        private IDressInstruction InstantiateDress(CodeInterview.WeatherDress.Core.Utils.Dress dressCommand)
        {
            IStateManager   stateManager    = (IStateManager)ScenarioContext.Current["DressState"];
            WeatherDressing weatherTypeMock = (WeatherDressing)ScenarioContext.Current["WeatherType"];

            switch (dressCommand)
            {
            case CodeInterview.WeatherDress.Core.Utils.Dress.Pajamas_Off:
                return(new PajamasInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.ShirtOn:
                return(new ShirtInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.PantsOn:
                return(new PantsInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.JacketOn:
                return(new JacketInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.SocksOn:
                return(new SocksInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.HeadwearOn:
                return(new HeadwearInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.FootwearOn:
                return(new FootwearInstruction(weatherTypeMock, stateManager));

            case CodeInterview.WeatherDress.Core.Utils.Dress.LeaveHouse:
                return(new LeaveHouseInstruction(weatherTypeMock, stateManager));

            default:
                throw new Exception("Invalid Command");
            }
        }