示例#1
0
        public void ShouldRaiseLowFuel()
        {
            var fuelManagement = new FuelManagement();
            var handler        = Substitute.For <EventHandler <LowFuelWarningEventArgs> >();

            fuelManagement.LowFuelDetected += handler;
            fuelManagement.DoSomething();
            handler.Received().Invoke(fuelManagement, Arg.Is <LowFuelWarningEventArgs>(x => x.PercentLeft < 20));
        }
示例#2
0
        public void ShouldRaiseLowFuel_WithoutNSub()
        {
            var fuelManagement = new FuelManagement();
            var eventWasRaised = false;

            fuelManagement.LowFuelDetected += (o, e) => eventWasRaised = true;
            fuelManagement.DoSomething();
            Assert.True(eventWasRaised);
        }