public void NullArgumentsArePassedToAction()
        {
            MyArgument value = new MyArgument();

            this.action = s => value = s;

            this.testee.Execute(null);

            value.Should().Be(null);
        }
        public void ActionIsInvokedWithSameArgumentThatIsPassedToActionHolderExecuted()
        {
            var        expected = new MyArgument();
            MyArgument value    = null;

            void AnAction(MyArgument x) => value = x;

            var testee = new ArgumentActionHolder <MyArgument>(AnAction);

            testee.Execute(expected);

            value.Should().Be(expected);
        }
Exemplo n.º 3
0
        public void ActionIsInvokedWithSameArgumentThatIsPassedToConstructor()
        {
            var        expected = new MyArgument();
            var        wrong    = new MyArgument();
            MyArgument value    = null;

            void AnAction(MyArgument x) => value = x;

            var testee = new ParametrizedActionHolder <MyArgument>(AnAction, expected);

            testee.Execute(wrong);

            value.Should().Be(expected);
        }
        public async Task AsyncActionIsInvokedWithSameArgumentThatIsPassedTGuardHolderExecuted()
        {
            var        expected = new MyArgument();
            MyArgument value    = null;

            Task <bool> AsyncGuard(MyArgument x)
            {
                value = x;
                return(Task.FromResult(true));
            }

            var testee = new ArgumentGuardHolder <MyArgument>(AsyncGuard);

            await testee.Execute(expected);

            value.Should().Be(expected);
        }
        public async Task SyncActionIsInvokedWithSameArgumentThatIsPassedToGuardHolderExecuted()
        {
            var        expected = new MyArgument();
            MyArgument value    = null;

            bool SyncGuard(MyArgument x)
            {
                value = x;
                return(true);
            }

            var testee = new ArgumentGuardHolder <MyArgument>(SyncGuard);

            await testee.Execute(expected);

            value.Should().Be(expected);
        }
        public async Task AsyncActionIsInvokedWithSameArgumentThatIsPassedToActionHolderExecuted()
        {
            var        expected = new MyArgument();
            MyArgument value    = null;

            Task AsyncAction(MyArgument x)
            {
                value = x;
                return(Task.CompletedTask);
            }

            var testee = new ArgumentActionHolder <MyArgument>(AsyncAction);

            await testee.Execute(expected);

            value.Should().Be(expected);
        }
        public async Task AsyncActionIsInvokedWithSameArgumentThatIsPassedToConstructor()
        {
            var        expected = new MyArgument();
            var        wrong    = new MyArgument();
            MyArgument value    = null;

            Task AsyncAction(MyArgument x)
            {
                value = x;
                return(Task.CompletedTask);
            }

            var testee = new ParametrizedActionHolder <MyArgument>(AsyncAction, expected);

            await testee.Execute(wrong);

            value.Should().Be(expected);
        }