コード例 #1
0
        public void FileArgDoesNotExist( )
        {
            InterfaceSpecBoilerPlateHelper <ICli2> isbph = new InterfaceSpecBoilerPlateHelper <ICli2>(
                new[] {
                Path.Combine(
                    __tempBaseDirDI.FullName,
                    "as.df")
            });

            IList <ISolution <IParserResult> > solutions = null;

            isbph.Config.UserPrompt = solutions2 => {
                solutions = solutions2;
                return(solutions2.FirstOrDefault(
                           solution => solution.Actions.Any(
                               action => action is GenericAction <IParserResult> genericAction &&
                               genericAction.Description.Equals("cancel"))));
            };

            Exception exc = null;

            try {
                ICli2 unused = isbph.CliConfigObject;
            } catch (Exception exc2) {
                exc = exc2;
            }

            Assert.IsNotNull(solutions);
            Assert.IsNotNull(exc);
            Assert.AreEqual("unresolved conflicts", exc.Message);
        }
コード例 #2
0
        public void FileArgExists( )
        {
            FileInfo fi = new FileInfo(
                Path.Combine(
                    __tempBaseDirDI.FullName,
                    "qw.ert"));

            try {
                fi.Create( );
                InterfaceSpecBoilerPlateHelper <ICli2> isbph = new InterfaceSpecBoilerPlateHelper <ICli2>(
                    new[] {
                    Path.Combine(
                        __tempBaseDirDI.FullName,
                        "qw.ert")
                });

                IList <ISolution <IParserResult> > solutions = null;
                isbph.Config.UserPrompt = solutions2 => {
                    solutions = solutions2;
                    return(solutions2.FirstOrDefault(
                               solution => solution.Actions.Any(
                                   action => action is GenericAction <IParserResult> genericAction &&
                                   genericAction.Description.Equals("cancel"))));
                };

                Exception exc = null;
                ICli2     cli = null;
                try {
                    cli = isbph.CliConfigObject;
                } catch (Exception exc2) {
                    exc = exc2;
                }

                Assert.IsNull(solutions);
                Assert.IsNull(exc);
                Assert.IsNotNull(cli);
                Assert.IsNotNull(cli.FileArg);
                Assert.IsTrue(cli.FileArg.Exists);
            } finally {
                fi.Delete( );
            }
        }
コード例 #3
0
        public void ResolveOptionArg( )
        {
            InterfaceSpecBoilerPlateHelper <ICli2> isbph =
                new InterfaceSpecBoilerPlateHelper <ICli2>(
                    new[] {
                "-o",
                Value.ToString( )
            });

            List <ISolution <IParserResult> > solutions = null;

            isbph.Config.UserPrompt = list => {
                solutions = list.ToList( );
                return(list.First( ));
            };

            ICli2 cli = isbph.CliConfigObject;

            Assert.IsNull(solutions);
            Assert.AreEqual(Value, cli.Arg);
        }