public void ResetHasExpectedResult() { _sut.Reset(); _sut.HasRecordedEvents.ShouldBeFalse(); _sut.RecordedEvents.ShouldBeEmpty(); }
public void RaceConditionTest() { var correctObject = new object(); var eventRecorder = new EventRecorder(); var test = new TestClass(); test.SetEventRecorder(eventRecorder); for (int i = 0; i < 1000; i++) { test.Write(correctObject); var assertTask = Task.Run(() => { var actualObj = test.Read(); if (eventRecorder.Events.StartsWith("WriteRead")) { Assert.True(object.ReferenceEquals(correctObject, actualObj), $"Failed on {i} iteration"); } }); var failTask = Task.Run(() => test.Write(new object())); Task.WaitAll(assertTask, failTask); eventRecorder.Reset(); } }
public ResetInstance() { _sut = new EventRecorder(); var record1 = new LocalEvent(); var record2 = new LocalEvent(); _sut.Record(record1); _sut.Record(record2); _sut.Reset(); }
public void ResetDoesNotThrow() { Assert.DoesNotThrow(() => _sut.Reset()); }
/// <summary> /// Clears the state changes. /// </summary> public void ClearChanges() { _recorder.Reset(); }
object[] IEmitEvents.TakeEvents() => _events.Reset();
object[] IEventSource.TakeEvents() => _events.Reset();