MeGaDeTH_91

NegativePressure

Apr 9th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Mock<ISensor> mockSensor = new Mock<ISensor>();
  2.  
  3. mockSensor.Setup(s => s.PopNextPressurePsiValue()).Returns(-10);
  4.  
  5. Type alarmType = typeof(Alarm);
  6.  
  7. Alarm classInstance = (Alarm)Activator.CreateInstance(alarmType);
  8. FieldInfo sensor = alarmType.GetField("_sensor", BindingFlags.Instance | BindingFlags.NonPublic);
  9. MethodInfo checkMethod = alarmType.GetMethod("Check", BindingFlags.Instance | BindingFlags.Public);
  10.  
  11. sensor.SetValue(classInstance, mockSensor.Object);
  12.  
  13. Assert.Throws<ArgumentOutOfRangeException>(() => classInstance.Check());
Advertisement
Add Comment
Please, Sign In to add comment