public void NullSenderAndCustomEventArguments()
        {
            "when raising generic event passing arguments and null sender"
            .x(() => Fake.GenericEvent += Raise.With(null, this.customEventArgs));

            "it should pass null as the sender"
            .x(() => CapturedSender.Should().BeNull());

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void CustomEventHandler()
        {
            "when raising custom event passing sender and arguments"
            .x(() => Fake.CustomEvent += Raise.With <CustomEventHandler>(SampleSender, this.customEventArgs));

            "it should pass the sender"
            .x(() => CapturedSender.Should().BeSameAs(SampleSender));

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void SenderAndCustomEventArguments()
        {
            "when raising generic event passing sender and arguments"
            .x(() => Fake.GenericEvent += Raise.With(SampleSender, this.customEventArgs));

            "it should pass the sender"
            .x(() => CapturedSender.Should().BeSameAs(SampleSender));

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void CustomEventArguments()
        {
            "when raising generic event passing arguments"
            .x(() => Fake.GenericEvent += Raise.With(this.customEventArgs));

            "it should pass the fake as sender"
            .x(() => CapturedSender.Should().BeSameAs(Fake));

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void SenderAndEventArguments()
        {
            "when raising event passing sender and arguments"
            .x(() => Fake.SubscribedEvent += Raise.With(SampleSender, this.eventArgs));

            "it should pass the sender"
            .x(() => CapturedSender.Should().BeSameAs(SampleSender));

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.eventArgs));
        }
        public void EventArguments()
        {
            "when raising event passing arguments"
            .x(() => Fake.SubscribedEvent += Raise.With(this.eventArgs));

            "it should pass the fake as sender"
            .x(() => CapturedSender.Should().BeSameAs(Fake));

            "it should pass the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.eventArgs));
        }
        public void WithEmpty()
        {
            "when raising event with empty arguments"
            .x(() => Fake.SubscribedEvent += Raise.WithEmpty());

            "it should pass the fake as sender"
            .x(() => CapturedSender.Should().BeSameAs(Fake));

            "it should pass empty event arguments"
            .x(() => CapturedArgs1.Should().Be(EventArgs.Empty));
        }
        public void CustomEventHandler()
        {
            "Given an event of a custom delegate type that takes a sender and event arguments"
            .See(() => nameof(Fake.CustomEvent));

            "When I raise the event specifying the sender and the event arguments"
            .x(() => Fake.CustomEvent += Raise.With <CustomEventHandler>(SampleSender, this.customEventArgs));

            "Then the supplied sender is passed as the event sender"
            .x(() => CapturedSender.Should().BeSameAs(SampleSender));

            "And the supplied value is passed as the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void EventArgumentsThatDoNotExtenedEventArg()
        {
            "Given an event of type EventHandler with custom event arguments type that does not extend EventArgs"
            .See(() => nameof(Fake.EventHandlerOfNonEventArgsEvent));

            "When I raise the event specifying only the event arguments"
            .x(() => Fake.EventHandlerOfNonEventArgsEvent += Raise.With(this.referenceTypeEventArgs));

            "Then the fake is passed as the sender"
            .x(() => CapturedSender.Should().BeSameAs(Fake));

            "And the supplied value is passed as the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.referenceTypeEventArgs));
        }
        public void NullSenderAndCustomEventArguments()
        {
            "Given an event of type EventHandler with custom event arguments type"
            .See(() => nameof(Fake.GenericEvent));

            "When I raise the event specifying the event arguments and a null sender"
            .x(() => Fake.GenericEvent += Raise.With(null, this.customEventArgs));

            "Then null is passed as the event sender"
            .x(() => CapturedSender.Should().BeNull());

            "And the supplied value is passed as the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.customEventArgs));
        }
        public void SenderAndEventArguments()
        {
            "Given an event of type EventHandler"
            .See(() => nameof(Fake.SubscribedEvent));

            "When I raise the event specifying the sender and the event arguments"
            .x(() => Fake.SubscribedEvent += Raise.With(SampleSender, this.eventArgs));

            "Then the supplied sender is passed as the event sender"
            .x(() => CapturedSender.Should().BeSameAs(SampleSender));

            "And the supplied value is passed as the event arguments"
            .x(() => CapturedArgs1.Should().BeSameAs(this.eventArgs));
        }
        public void WithEmpty()
        {
            "Given an event of type EventHandler"
            .See(() => nameof(Fake.SubscribedEvent));

            "When I raise the event without specifying sender or arguments"
            .x(() => Fake.SubscribedEvent += Raise.WithEmpty());

            "Then the fake is passed as the sender"
            .x(() => CapturedSender.Should().BeSameAs(Fake));

            "And an empty EventArgs is passed as the event arguments"
            .x(() => CapturedArgs1.Should().Be(EventArgs.Empty));
        }