Exemple #1
0
        protected override void SetContext()
        {
            MockConverters      = Substitute.For <IDataConverters>();
            MockDisplayStrategy = Substitute.For <IDisplayStrategy>();

            SUT = new WeatherAppModel(MockConverters, MockDisplayStrategy);
        }
        public WeatherAppModel(IDataConverters dataConverters, IDisplayStrategy displayStrategy)
        {
            _dataConverters        = dataConverters;
            _displayStrategy       = displayStrategy;
            _currentDownloadStatus = DownloadProgressEnum.Completed;
            _connectionAPIs        = new List <string>
            {
                "http://localhost:60350/Weather/",
                "http://localhost:60368/"
            };

            _speeds = new List <string>
            {
                MPH,
                KPH
            };

            _temperatures = new List <string>
            {
                Celsius,
                Fahrenheit
            };

            _displayConverters = new Dictionary <string, Func <double, double> >
            {
                { MPH, d => _dataConverters.KPHtoMPH(d) },
                { Fahrenheit, d => _dataConverters.CelciusToFahrenHeight(d) }
            };

            _speedData       = new List <double>();
            _temperatureData = new List <double>();

            _currentSpeedType = _speeds.First();
            _currentTempType  = _temperatures.First();
        }
        public void ReConfigure(IPayStationFactory payStationFactory)
        {
            _payStationFactory = payStationFactory;

            _coinValidationStrategy = _payStationFactory.CreateCoinValidationStrategy();
            _rateStrategy = _payStationFactory.CreateRateStrategy();
            _displayStrategy = _payStationFactory.CreateDisplayStrategy();
        }
Exemple #4
0
        public void ReConfigure(IPayStationFactory payStationFactory)
        {
            _payStationFactory = payStationFactory;

            _coinValidationStrategy = _payStationFactory.CreateCoinValidationStrategy();
            _rateStrategy           = _payStationFactory.CreateRateStrategy();
            _displayStrategy        = _payStationFactory.CreateDisplayStrategy();
        }
Exemple #5
0
        public SimulationConfig(List<String> argv)
        {
            if (argv.Contains("-p")) {
            this._displayStrategy = new BoardPrint();
              }

              foreach (string arg in argv) {
            string f = "../../in/" + arg;
            Console.WriteLine(f);
            if (File.Exists(f)) {
              _inputFile = f;
              break;
            }
              }
        }
Exemple #6
0
        /** Class constructor. Sets up initial simulation configuration. */
        public Simulation(String inputFile, IDisplayStrategy displayStrategy)
        {
            string line;
              this.displayStrategy = displayStrategy;

              // Read the file and display it line by line.
              System.IO.StreamReader file = new System.IO.StreamReader(inputFile);

              while ((line = file.ReadLine()) != null) {
            String[] tokens = line.Split(',');
            String type = tokens[0];
            int x = int.Parse(tokens[1]);
            int y = int.Parse(tokens[2]);
            String movementStrategy = tokens[3];
            String feeding = tokens[4];

            String[] feedingTokens = feeding.Split(' ');
            String feedingStrategy = feedingTokens[0];

            morgs.Add(morgFactory.createMorg(type, x, y, movementStrategy, feedingStrategy, feedingTokens));
              }
              file.Close();
        }
 public Dog(IDisplayStrategy p_displayStrategy, IEatStrategy p_eatStrategy, ITypeStrategy p_typeStrategy)
 {
     m_displayStrategy = p_displayStrategy;
     m_eatStrategy     = p_eatStrategy;
     m_typeStrategy    = p_typeStrategy;
 }
Exemple #8
0
 public App(IInputStrategy inputStrategy, ICalculationStrategy calculationStrategy, IDisplayStrategy displayStrategy)
 {
     _inputStrategy       = inputStrategy;
     _calculationStrategy = calculationStrategy;
     _displayStrategy     = displayStrategy;
 }
Exemple #9
0
 public Duck(IFlyingStrategy flyingStrategy, IQuarkingStrategy quarkingStrategy, IDisplayStrategy displayStrategy)
 {
     this.flyingStrategy   = flyingStrategy;
     this.quarkingStrategy = quarkingStrategy;
     this.displayStrategy  = displayStrategy;
 }