Completed
Last Updated: 21 Oct 2020 09:33 by ADMIN
Ivo
Created on: 19 Aug 2020 09:26
Type: Bug Report
4
JustMock fails to raise internal events

The internal (non-public) events are not handled properly by JustMock, there is no indication for error, Raise arrangement simply does not working as expected. The following sample reproduces the issue:

namespace TestExample
{
    public class ClassWithEvents
    {
        internal event EventHandler<EventArgs> InternalEventToTest;
    }

    [TestClass()]
    public class EventTests
    {
        [TestMethod]
        public void ClassWithEvents_InternalEventTest()
        {
            //Arrange
            bool eventRaised = false;
            ClassWithEvents classWithEvents = Mock.Create<ClassWithEvents>();
            classWithEvents.InternalEventToTest += (object sender, EventArgs e) =>
            {
                eventRaised = true;
            };

            // Act
            Mock.Raise(() => classWithEvents.InternalEventToTest += null, new EventArgs());

            // Assert
            Assert.IsTrue(eventRaised);
        }
    }
}

1 comment
ADMIN
Mihail
Posted on: 21 Oct 2020 09:33

The fix is available with R3 SP1 2020 release (2020.3.1019.2).

Regards,
Mihail
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).