Esempio n. 1
0
            public void ResetHasExpectedResult()
            {
                _sut.Reset();

                _sut.HasRecordedEvents.ShouldBeFalse();
                _sut.RecordedEvents.ShouldBeEmpty();
            }
Esempio n. 2
0
    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();
        }
    }
Esempio n. 3
0
            public ResetInstance()
            {
                _sut = new EventRecorder();

                var record1 = new LocalEvent();
                var record2 = new LocalEvent();

                _sut.Record(record1);
                _sut.Record(record2);
                _sut.Reset();
            }
Esempio n. 4
0
 public void ResetDoesNotThrow()
 {
     Assert.DoesNotThrow(() => _sut.Reset());
 }
Esempio n. 5
0
 /// <summary>
 /// Clears the state changes.
 /// </summary>
 public void ClearChanges()
 {
     _recorder.Reset();
 }
Esempio n. 6
0
 object[] IEmitEvents.TakeEvents() => _events.Reset();
Esempio n. 7
0
 object[] IEventSource.TakeEvents() => _events.Reset();