public void Setup() { // Initialize event counters _increaseTempEventsReceived = 0; _decreaseTempEventsreceived = 0; _tempSource = Substitute.For <ITempSource>(); _uut = new Control(_tempSource, 25); // Control should hook up to event source // Initialize anonymous event listeners that listen to events from Control // See e.g. http://nsubstitute.github.io/help/raising-events/ _uut.IncreaseTempEvent += (sender, args) => { ++_increaseTempEventsReceived; }; _uut.DecreaseTempEvent += (sender, args) => { ++_decreaseTempEventsreceived; }; }
public Control(ITempSource tempSource, int threshold) { tempSource.TempChangedEvent += HandleTempChangedEvent; Threshold = threshold; }