Ejemplo n.º 1
0
        void RaiseEventManually()
        {
            var mock = new Mock <IEventType>();
            var sut  = new AnEventUser(mock.Object);

            mock.Raise(x => x.TheEvent += null, new AnEventArg()
            {
                Value = 42
            });

            Assert.Equal <int>(42, sut.Received);
        }
Ejemplo n.º 2
0
        void RaiseEventOnFunctionCall()
        {
            var mock = new Mock <IEventType>();
            var sut  = new AnEventUser(mock.Object);

            int value = 42;

            mock.Setup(x => x.TheOperation(value))
            .Raises(x => x.TheEvent += null, new AnEventArg()
            {
                Value = value
            });

            // This is just to trigger the call on a function
            // Sould be placed inside a second sut
            mock.Object.TheOperation(value);

            Assert.Equal <int>(value, sut.Received);
        }