public void CreateExtendedCommandInvalidBaseCommandReturnsOriginalCommand()
        {
            var sut     = new SutAlias();
            var command = CreateWrappedMethodInvokeCommand(
                new Mock <IMethod>().Object,
                new Mock <IExpansion <object> >().Object);

            var actual = sut.CreateExtendedCommand(new Mock <ISpecimenBuilder>().Object, command);

            Assert.Same(command, actual);
        }
        public void TryGetMethodInvokeCommandDoesNotContainMethodInvokeCommandReturnsFalse()
        {
            var sut = new SutAlias();
            MethodInvokeCommand methodInvokeCommand;

            var actual = sut.TryGetMethodInvokeCommand(
                new Mock <IGuardClauseCommand>().Object,
                out methodInvokeCommand);

            Assert.False(actual);
            Assert.Null(methodInvokeCommand);
        }
        public void TryGetMethodInvokeCommandHasMethodInvokeCommandReturnsCommand()
        {
            var sut = new SutAlias();
            MethodInvokeCommand methodInvokeCommand;
            var command = CreateWrappedMethodInvokeCommand(
                new Mock <IMethod>().Object,
                new Mock <IExpansion <object> >().Object);

            var actual = sut.TryGetMethodInvokeCommand(command, out methodInvokeCommand);

            Assert.True(actual);
            Assert.NotNull(methodInvokeCommand);
        }
        public void CreateExtendedCommandWithStaticMethodReturnsMethodInvokeCommand()
        {
            var sut        = new SutAlias();
            var methodInfo = typeof(GuardClauseExtensionsTests).GetMethod(
                nameof(StaticCommandHelperMethod),
                BindingFlags.Static | BindingFlags.NonPublic);
            var method  = new StaticMethod(methodInfo);
            var command = CreateWrappedMethodInvokeCommand(
                method,
                new IndexedReplacement <object>(0));

            var actual = sut.CreateExtendedCommand(new Mock <ISpecimenBuilder>().Object, command);

            Assert.IsType <MethodInvokeCommand>(
                (actual as ReflectionExceptionUnwrappingCommand)?.Command);
        }
        public void TryGetMethodInvokeCommandHasTaskTypeMethodInvokeCommandReturnsCommand()
        {
            var sut = new SutAlias();
            var testHelperMethod = typeof(GuardClauseExtensionsTests)
                                   .GetMethod(
                nameof(StaticCommandHelperMethod),
                BindingFlags.Static | BindingFlags.NonPublic);
            var innerCommand = new ReflectionExceptionUnwrappingCommand(new MethodInvokeCommand(
                                                                            new Mock <IMethod>().Object,
                                                                            new Mock <IExpansion <object> >().Object,
                                                                            testHelperMethod.GetParameters().First()));
            var command =
                (IGuardClauseCommand)Activator.CreateInstance(TaskReturnType, innerCommand);
            MethodInvokeCommand methodInvokeCommand;

            var actual = sut.TryGetMethodInvokeCommand(command, out methodInvokeCommand);

            Assert.True(actual);
            Assert.NotNull(methodInvokeCommand);
        }