public static void GotExpectedEvent() { var x = new RaisingClass(); var evt = Assert.RaisesAny<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(EventArgs.Empty)); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(EventArgs.Empty, evt.Arguments); }
public static void GotExpectedEvent() { var x = new RaisingClass(); var evt = Assert.RaisesAny <EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(EventArgs.Empty)); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(EventArgs.Empty, evt.Arguments); }
public static async Task GotExpectedEvent() { var x = new RaisingClass(); var evt = await Assert.RaisesAsync <EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(EventArgs.Empty))); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(EventArgs.Empty, evt.Arguments); }
public static void GotDerivedEvent() { var x = new RaisingClass(); var args = new DerivedEventArgs(); var evt = Assert.RaisesAny <EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(args)); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(args, evt.Arguments); }
public static async Task GotDerivedEvent() { var x = new RaisingClass(); var args = new DerivedEventArgs(); var evt = await Assert.RaisesAnyAsync <EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(args))); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(args, evt.Arguments); }
public static void ExpectedEventButRaisesEventWithDerivedArgs() { var x = new RaisingClass(); var recorded = Record.Exception(() => Assert.Raises<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(new DerivedEventArgs()))); var exception = Assert.IsType<RaisesException>(recorded); Assert.Equal("DerivedEventArgs", exception.Actual); Assert.Equal("EventArgs", exception.Expected); Assert.Equal("(Raised event did not match expected event)", exception.UserMessage); }
public static void GotExpectedEvent() { var x = new RaisingClass(); var genericObject = new object(); var evt = Assert.RaisesAny <object>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(genericObject) ); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(genericObject, evt.Arguments); }
public static async Task GotExpectedEvent() { var x = new RaisingClass(); var genericObject = new object(); var evt = await Assert.RaisesAsync <object>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(genericObject)) ); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(genericObject, evt.Arguments); }
public static void ExpectedEventButRaisesEventWithDerivedArgs() { var x = new RaisingClass(); var recorded = Record.Exception(() => Assert.Raises <EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(new DerivedEventArgs()))); var exception = Assert.IsType <RaisesException>(recorded); Assert.Equal("DerivedEventArgs", exception.Actual); Assert.Equal("EventArgs", exception.Expected); Assert.Equal("(Raised event did not match expected event)", exception.UserMessage); }
public static void ExpectedEventButRaisesEventWithDerivedArgs() { try { var x = new RaisingClass(); Assert.Raises<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(new DerivedEventArgs())); } catch (RaisesException exception) { Assert.Equal("DerivedEventArgs", exception.Actual); Assert.Equal("EventArgs", exception.Expected); Assert.Equal("(Raised event did not match expected event)", exception.UserMessage); } }
public static async Task ExpectedEventButRaisesEventWithDerivedObject() { var x = new RaisingClass(); var recorded = await Record.ExceptionAsync(() => Assert.RaisesAsync <object>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(new DerivedObject())) ) ); var exception = Assert.IsType <RaisesException>(recorded); Assert.Equal("DerivedObject", exception.Actual); Assert.Equal("Object", exception.Expected); Assert.Equal("(Raised event did not match expected event)", exception.UserMessage); }
public static void GotDerivedEvent() { var x = new RaisingClass(); var args = new DerivedEventArgs(); var evt = Assert.RaisesAny<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => x.RaiseWithArgs(args)); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(args, evt.Arguments); }
public static async Task GotExpectedEvent() { var x = new RaisingClass(); var evt = await Assert.RaisesAsync<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(EventArgs.Empty))); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(EventArgs.Empty, evt.Arguments); }
public static async Task GotDerivedEvent() { var x = new RaisingClass(); var args = new DerivedEventArgs(); var evt = await Assert.RaisesAnyAsync<EventArgs>( h => x.Completed += h, h => x.Completed -= h, () => Task.Run(() => x.RaiseWithArgs(args))); Assert.NotNull(evt); Assert.Equal(x, evt.Sender); Assert.Equal(args, evt.Arguments); }