public void CheckingAlarmTwiceShouldCallSensorTwice()
 {
     MockRepository mocks = new MockRepository();
     ISensor sensor = mocks.StrictMock<ISensor>();
     Expect.Call(sensor.PopNextPressurePsiValue()).Return(16.00).Repeat.Twice();
     IAlarm alarm = new Alarm(sensor, new DefaultChecker());
     mocks.ReplayAll();
     alarm.Check();
     alarm.Check();
     sensor.VerifyAllExpectations();
 }
Пример #2
0
        public void asd()
        {
            //Arange
            var mock = new Mock<ISensor>();
            mock.Setup(r => r.PopNextPressurePsiValue())
                .Returns(1);

            Sensor sensor = new Sensor(this.rndNumProv);
            Alarm alarm = new Alarm(mock.Object);

            Assert.IsFalse(alarm.AlarmOn);
        }
Пример #3
0
        public static void Main()
        {
            Random rnd = new Random();
            RandomNumberProvider rndNumProv = new RandomNumberProvider(rnd);

            Sensor sensor = new Sensor(rndNumProv);

            Alarm alarm = new Alarm(sensor);
            for (int i = 0; i < 10; i++)
            {
                alarm.Check();
                Console.WriteLine(alarm.AlarmOn);
            }
        }
        public void APressure18FollowedByPressure16MeansAlarmOffAndOn()
        {
            MockRepository mocks = new MockRepository();
            ISensor sensor = mocks.StrictMock<ISensor>();

            Expect.Call(sensor.PopNextPressurePsiValue()).Return(18.00).Repeat.Once();
            Expect.Call(sensor.PopNextPressurePsiValue()).Return(16.00).Repeat.Once();
            mocks.ReplayAll();

            IAlarm alarm = new Alarm(sensor, new DefaultChecker());

            alarm.Check();
            Assert.IsFalse(alarm.AlarmOn);

            alarm.Check();
            Assert.IsTrue(alarm.AlarmOn);

            sensor.VerifyAllExpectations();
        }
Пример #5
0
 public void TestMethod1()
 {
     Alarm alarm = new Alarm();
     alarm.
 }
Пример #6
0
 public void Foo()
 {
     Alarm alarm = new Alarm();
     Assert.AreEqual(false, alarm.AlarmOn);
 }
 public void when_the_pressure_in_over_18_the_alarm_is_off_with_rhino_mock()
 {
     MockRepository mocks = new MockRepository();
     ISensor sensor = mocks.StrictMock<ISensor>();
     Expect.Call(sensor.PopNextPressurePsiValue()).Return(18.00);
     IAlarm alarm = new Alarm(sensor,new DefaultChecker());
     mocks.ReplayAll();
     alarm.Check();
     Assert.IsFalse(alarm.AlarmOn);
     sensor.VerifyAllExpectations();
 }
        public void noCallToAlarmSoNoCallToSensor()
        {
            MockRepository mocks = new MockRepository();
            ISensor sensor = mocks.StrictMock<ISensor>();
            Expect.Call(sensor.PopNextPressurePsiValue()).Return(18.00);
            IAlarm alarm = new Alarm(sensor, new DefaultChecker());
            mocks.ReplayAll();

            sensor.VerifyAllExpectations();
        }
 public void For_A_Value_of_pressure_18_TheAlarmShould_be_off()
 {
     Alarm alarm = new Alarm(new MockSensor(18),new DefaultChecker());
     alarm.Check();
     Assert.IsFalse(alarm.AlarmOn);
 }