예제 #1
0
        public void NotifyComplete_ShouldCallSubjectOnComplete(
            [Frozen] TestScheduler scheduler,
            CommandEvents sut,
            TestCommand command)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyComplete(command));

            //act
            var resultObserver = scheduler.Start(() => sut.ObserveCommandEvents <TestCommand, string>(command), 500);

            //assert
            resultObserver.AssertExceptions();
            resultObserver.Completed().Should().HaveCount(1);
        }
예제 #2
0
        public void NotifyError_ShouldCallSubjectOnError(
            [Frozen] TestScheduler scheduler,
            CommandEvents sut,
            TestCommand command,
            Exception error)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyError(command, error));

            //act
            var resultObserver = scheduler.Start(() => sut.ObserveCommandEvents <TestCommand, string>(command), 500);

            //assert
            resultObserver.Errors().ShouldAllBeEquivalentTo(new[] { error });
        }
예제 #3
0
        public void ObserveCommandEvents_WhenNotifyingOtherType_ShouldNotYieldValue(
            [Frozen] TestScheduler scheduler,
            CommandEvents sut,
            TestCommandWithMultipleEvents command,
            int value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var resultObserver = scheduler.Start(() => sut.ObserveCommandEvents <TestCommandWithMultipleEvents, string>(command), 500);

            //assert
            resultObserver.AssertExceptions();
            resultObserver.Values().Should().BeEmpty();
        }
예제 #4
0
        public void ObserveCommandEvents_CommandHaveMultipleEventsWhenNotifying_ShouldYieldValue(
            [Frozen] TestScheduler scheduler,
            CommandEvents sut,
            TestCommandWithMultipleEvents command,
            string value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var resultObserver = scheduler.Start(() => sut.ObserveCommandEvents <TestCommandWithMultipleEvents, string>(command), 500);

            //assert
            resultObserver.AssertExceptions();
            resultObserver.Values().ShouldAllBeEquivalentTo(new[] { value });
        }
예제 #5
0
        public void ObserveCommandEvents_WithoutCommandAndWhenNotifyingOtherType_ShouldReturnCorrectValue(
            [Frozen] ThrowingTestScheduler scheduler,
            CommandEvents sut,
            TestCommandWithMultipleEvents command,
            string value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var result = scheduler.Start(() => sut.ObserveCommandEvents <TestCommandWithMultipleEvents, int>());

            //assert
            result.AssertExceptions();
            result.Values().Should().BeEmpty();
        }
예제 #6
0
        public void ObserveCommandEvents_ShouldReturnCorrectValue(
            [Frozen] ThrowingTestScheduler scheduler,
            CommandEvents sut,
            TestCommand command,
            string value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var result = scheduler.Start(() => sut.ObserveCommandEvents <TestCommand, string>());

            //assert
            result.AssertExceptions();
            result.Values().First().Should().Be(value);
        }