Exemplo n.º 1
0
        public void NextIsRaining()
        {
            IMock         random  = new DynamicMock(typeof(System.Random));
            WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);

            random.SetupResult("NextDouble", 0.0);
            Assertion.Assert("is raining", weather.NextIsRaining());

            random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
            Assertion.Assert("is not raining", !weather.NextIsRaining());

            random.SetupResult("NextDouble", 1.0);
            Assertion.Assert("is not raining", !weather.NextIsRaining());
        }
Exemplo n.º 2
0
		public void NextIsRaining()
		{
			IMock random = new DynamicMock(typeof(System.Random));
			WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);

			random.SetupResult("NextDouble", 0.0);
			Assertion.Assert("is raining", weather.NextIsRaining());

			random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
			Assertion.Assert("is not raining", !weather.NextIsRaining());

			random.SetupResult("NextDouble", 1.0);
			Assertion.Assert("is not raining", !weather.NextIsRaining());
		}
Exemplo n.º 3
0
        public void NextTemperature()
        {
            IMock         random  = new DynamicMock(typeof(System.Random));
            WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);

            random.SetupResult("NextDouble", 0.0);
            Assertion.AssertEquals("should be min temperature",
                                   DefaultWeatherRandom.MIN_TEMPERATURE,
                                   weather.NextTemperature()
                                   );

            random.SetupResult("NextDouble", 0.5);
            Assertion.AssertEquals("should be average temperature",
                                   0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
                                   weather.NextTemperature()
                                   );

            random.SetupResult("NextDouble", 1.0);
            Assertion.AssertEquals("should be max temperature",
                                   DefaultWeatherRandom.MAX_TEMPERATURE,
                                   weather.NextTemperature()
                                   );
        }
Exemplo n.º 4
0
		public void NextTemperature()
		{
			IMock random = new DynamicMock(typeof(System.Random));
			WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);

			random.SetupResult("NextDouble", 0.0);
			Assertion.AssertEquals("should be min temperature",
				DefaultWeatherRandom.MIN_TEMPERATURE,
				weather.NextTemperature()
			);

			random.SetupResult("NextDouble", 0.5);
			Assertion.AssertEquals("should be average temperature",
				0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
				weather.NextTemperature()
			);

			random.SetupResult("NextDouble", 1.0);
			Assertion.AssertEquals("should be max temperature",
				DefaultWeatherRandom.MAX_TEMPERATURE,
				weather.NextTemperature()
			);
		}