public void ThrowIfNoStepInVeryStrictMode()
        {
            var eventMock = new EventMock <EventHandler>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var ex        = Assert.Throws <MockMissingException>(() => eventMock.Remove(_handler));

            Assert.Equal(MockType.EventRemove, ex.MemberType);
        }
        public void DoNothingIfClearedInLenientMode()
        {
            var eventMock = new EventMock <EventHandler>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep  = NextStepFor(eventMock);

            eventMock.Clear();
            eventMock.Remove(_handler);
            Assert.Equal(0, nextStep.AddCount);
            Assert.Equal(0, nextStep.RemoveCount);
        }
        public void SetStepUsedByRemove()
        {
            bool called  = false;
            var  newStep = new MockEventStep <EventHandler>();

            newStep.Remove.Action(_ => { called = true; });
            ((ICanHaveNextEventStep <EventHandler>)_eventMock).SetNextStep(newStep);
            _eventMock.Remove((sender, e) => { });
            Assert.True(called);
        }
        public void ThrowIfClearedInVeryStrictMode()
        {
            var eventMock = new EventMock <EventHandler>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.VeryStrict);
            var nextStep  = NextStepFor(eventMock);

            eventMock.Clear();
            var ex = Assert.Throws <MockMissingException>(() => eventMock.Remove(_handler));

            Assert.Equal(MockType.EventRemove, ex.MemberType);
            Assert.Equal(0, nextStep.AddCount);
            Assert.Equal(0, nextStep.RemoveCount);
        }
        public void SendMockInformationAndHandlerToStep()
        {
            var eventMock = new EventMock <EventHandler>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);
            var nextStep  = NextStepFor(eventMock);

            eventMock.Remove(_handler);

            Assert.Equal(0, nextStep.AddCount);
            Assert.Equal(1, nextStep.RemoveCount);
            Assert.Same(eventMock, nextStep.LastRemoveMockInfo);
            Assert.Equal(_handler, nextStep.LastRemoveValue);
        }
        public void DoNothingIfNoStepInLenientMode()
        {
            var eventMock = new EventMock <EventHandler>(new object(), "ClassName", "InterfaceName", "MemberName", "MockName", Strictness.Lenient);

            eventMock.Remove(_handler);
        }