|
From: <joe...@us...> - 2002-11-15 22:31:14
|
Update of /cvsroot/nmock/nmock/sample/random
In directory usw-pr-cvs1:/tmp/cvs-serv30242/sample/random
Modified Files:
WeatherTest.cs
Log Message:
- Added sensible error messages
- Renamed IMock.Object to IMock.MockInstance
- Renamed Conditions to Constraints and moved to new namespace.
- Renamed eval() to Eval() (.NET conventions).
- Renamed IMock.SetValue() to IMock.SetupResult (as in Java MockObjects).
Index: WeatherTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/sample/random/WeatherTest.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** WeatherTest.cs 10 Nov 2002 16:32:27 -0000 1.1.1.1
--- WeatherTest.cs 15 Nov 2002 22:31:10 -0000 1.2
***************
*** 16,20 ****
{
random = new DynamicMock(typeof(WeatherRandom));
! weather = new Weather((WeatherRandom)random.Object);
}
--- 16,20 ----
{
random = new DynamicMock(typeof(WeatherRandom));
! weather = new Weather((WeatherRandom)random.MockInstance);
}
***************
*** 22,27 ****
public void RandomRaining()
{
! random.SetValue("NextTemperature", 1.0);
! random.SetValue("NextIsRaining", true);
weather.Randomize();
Assertion.Assert("is raining", weather.IsRaining);
--- 22,27 ----
public void RandomRaining()
{
! random.SetupResult("NextTemperature", 1.0);
! random.SetupResult("NextIsRaining", true);
weather.Randomize();
Assertion.Assert("is raining", weather.IsRaining);
***************
*** 31,36 ****
public void RandomNotRaining()
{
! random.SetValue("NextTemperature", 1.0);
! random.SetValue("NextIsRaining", false);
weather.Randomize();
Assertion.Assert("is not raining", !weather.IsRaining);
--- 31,36 ----
public void RandomNotRaining()
{
! random.SetupResult("NextTemperature", 1.0);
! random.SetupResult("NextIsRaining", false);
weather.Randomize();
Assertion.Assert("is not raining", !weather.IsRaining);
***************
*** 41,46 ****
{
double TEMPERATURE = 20.0;
! random.SetValue("NextTemperature", TEMPERATURE);
! random.SetValue("NextIsRaining", false);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE, weather.Temperature);
--- 41,46 ----
{
double TEMPERATURE = 20.0;
! random.SetupResult("NextTemperature", TEMPERATURE);
! random.SetupResult("NextIsRaining", false);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE, weather.Temperature);
***************
*** 51,56 ****
{
double TEMPERATURE = 20.0;
! random.SetValue("NextTemperature", TEMPERATURE);
! random.SetValue("NextIsRaining", true);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE / 2.0, weather.Temperature);
--- 51,56 ----
{
double TEMPERATURE = 20.0;
! random.SetupResult("NextTemperature", TEMPERATURE);
! random.SetupResult("NextIsRaining", true);
weather.Randomize();
Assertion.AssertEquals("temperature", TEMPERATURE / 2.0, weather.Temperature);
***************
*** 67,79 ****
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.Object);
! random.SetValue("NextDouble", 0.0);
Assertion.Assert("is raining", weather.NextIsRaining());
! random.SetValue("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
Assertion.Assert("is not raining", !weather.NextIsRaining());
! random.SetValue("NextDouble", 1.0);
Assertion.Assert("is not raining", !weather.NextIsRaining());
}
--- 67,79 ----
{
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());
}
***************
*** 83,89 ****
{
IMock random = new DynamicMock(typeof(System.Random));
! WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.Object);
! random.SetValue("NextDouble", 0.0);
Assertion.AssertEquals("should be min temperature",
DefaultWeatherRandom.MIN_TEMPERATURE,
--- 83,89 ----
{
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,
***************
*** 91,95 ****
);
! random.SetValue("NextDouble", 0.5);
Assertion.AssertEquals("should be average temperature",
0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
--- 91,95 ----
);
! random.SetupResult("NextDouble", 0.5);
Assertion.AssertEquals("should be average temperature",
0.5 * (DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE),
***************
*** 97,101 ****
);
! random.SetValue("NextDouble", 1.0);
Assertion.AssertEquals("should be max temperature",
DefaultWeatherRandom.MAX_TEMPERATURE,
--- 97,101 ----
);
! random.SetupResult("NextDouble", 1.0);
Assertion.AssertEquals("should be max temperature",
DefaultWeatherRandom.MAX_TEMPERATURE,
|