예제 #1
0
            public void GivenList_AddsEntry()
            {
                var commandLineSwitch = CommandLineOptionFactory.CreateSwitches(_driver).First();
                var help = commandLineSwitch.CreateHelp().ToList();

                help.Should().HaveCount(1);
            }
            public void GivenNullInstance_ThrowsException()
            {
                var exception =
                    Assert.Throws <ArgumentNullException>(
                        () => CommandLineOptionFactory.CreateSwitches(null));

                exception.ParamName.Should().Be("instance");
            }
            public void GivenDriver_ReturnsParameterOfCorrectType()
            {
                var parameters
                    = CommandLineOptionFactory.CreateParameters(_driver);
                var uploadParameter = parameters.Single(p => p.Method.Name == "Upload");

                uploadParameter.Should().BeOfType <CommandLineParameter <string> >();
            }
            public void GivenNull_ThrowsException()
            {
                var exception =
                    Assert.Throws <ArgumentNullException>(
                        () => CommandLineOptionFactory.IsSwitch(null));

                exception.ParamName.Should().Be("method");
            }
        public void Ensure_CreateCommandLineOption_Returns_Expected_Object()
        {
            var factory = new CommandLineOptionFactory();

            const string expectedShortName = "my short name";
            const string expectedLongName = "my long name";

            var mockParserFactory = new Mock<ICommandLineOptionParserFactory>();
            mockParserFactory.Setup(x => x.CreateParser<string>()).Returns(Mock.Of<ICommandLineOptionParser<string>>);
            factory.ParserFactory = mockParserFactory.Object;

            var actual = factory.CreateOption<string>(expectedShortName, expectedLongName);

            Assert.IsInstanceOf<CommandLineOption<string>>(actual, "Factory returned unexpected object");
            Assert.AreEqual(expectedShortName, actual.ShortName, "Factory returned Option with unexpected ShortName");
            Assert.AreEqual(expectedShortName, actual.ShortName, "Factory returned Option with unexpected LongName");
        }
        public void Ensure_CreateCommandLineOption_Returns_Expected_Object()
        {
            var factory = new CommandLineOptionFactory();

            const string expectedShortName = "my short name";
            const string expectedLongName  = "my long name";

            var mockParserFactory = new Mock <ICommandLineOptionParserFactory>();

            mockParserFactory.Setup(x => x.CreateParser <string>()).Returns(Mock.Of <ICommandLineOptionParser <string> >);
            factory.ParserFactory = mockParserFactory.Object;

            var actual = factory.CreateOption <string>(expectedShortName, expectedLongName);

            Assert.IsInstanceOf <CommandLineOption <string> >(actual, "Factory returned unexpected object");
            Assert.AreEqual(expectedShortName, actual.ShortName, "Factory returned Option with unexpected ShortName");
            Assert.AreEqual(expectedShortName, actual.ShortName, "Factory returned Option with unexpected LongName");
        }
 public void GivenNullInstance_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => CommandLineOptionFactory.CreateParameters(null));
 }
            public void GivenSwitchMethod_ReturnsFalse()
            {
                var method = _driver.GetType().GetMethod("Debug");

                CommandLineOptionFactory.IsParameter(method).Should().BeFalse();
            }
            public void GivenParameterMethod_ReturnsTrue()
            {
                var method = _driver.GetType().GetMethod("Find");

                CommandLineOptionFactory.IsParameter(method).Should().BeTrue();
            }
 public void GivenNull_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => CommandLineOptionFactory.IsParameter(null));
 }
            public void GivenMethodWithParameters_ReturnsFalse()
            {
                var method = _driver.GetType().GetMethod("Find");

                CommandLineOptionFactory.IsSwitch(method).Should().BeFalse();
            }
            public void GivenMethodMissingDescription_ReturnsFalse()
            {
                var method = _driver.GetType().GetMethod("Verbose");

                CommandLineOptionFactory.IsSwitch(method).Should().BeFalse();
            }
            public void GivenSwitchMethod_ReturnsTrue()
            {
                var method = _driver.GetType().GetMethod("Debug");

                CommandLineOptionFactory.IsSwitch(method).Should().BeTrue();
            }
            public void GivenModelMethod_ReturnsTrue()
            {
                var method = _driver.GetType().GetMethod("TestPerformance");

                CommandLineOptionFactory.IsMode <BaseDriver>(method).Should().BeTrue();
            }
            public void GivenParameterMethod_ReturnsFalse()
            {
                var method = _driver.GetType().GetMethod("Find");

                CommandLineOptionFactory.IsMode <BaseDriver>(method).Should().BeFalse();
            }
            public void GivenModeMethod_ReturnsFalse()
            {
                var method = _driver.GetType().GetMethod("TestPerformance");

                CommandLineOptionFactory.IsSwitch(method).Should().BeFalse();
            }
            public void GivenDriver_ReturnsParameters()
            {
                var parameters = CommandLineOptionFactory.CreateParameters(_driver);

                parameters.Should().NotBeEmpty();
            }