示例#1
0
        public void RaisedEventDoesNotInvokeDettachedSubjectHandler()
        {
            var proxy = Mock.Create <IThermostatService>();

            proxy.Setup(p => p.SwitchOn());
            // ReSharper disable once UnusedVariable
            var controller = new ThemostatController(proxy);

            proxy.Raise(p => p.Cold += null, new EventArgs());

            proxy.Verify(p => p.SwitchOn(), Occurred.Never());
        }
示例#2
0
        public void RaisedEventPassesParameters()
        {
            const int temp  = 100;
            var       proxy = Mock.Create <IThermostatService>();

            proxy.Setup(p => p.ChangeTemp(temp));
            // ReSharper disable once UnusedVariable
            var controller = new ThemostatController(proxy);

            proxy.Raise(p => p.TempChanged += null, new TempChangedEventArgs(temp));

            proxy.Verify(p => p.ChangeTemp(temp), Occurred.Once());
        }