コード例 #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());
        }
コード例 #2
0
ファイル: WeatherTest.cs プロジェクト: bbriggs/FieldWorks
		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());
		}
コード例 #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()
                                   );
        }
コード例 #4
0
ファイル: WeatherTest.cs プロジェクト: bbriggs/FieldWorks
		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()
			);
		}