示例#1
0
        public void CreateReferenceAndSetSchemaToEmptyString_FailingTest()
        {
            Arguments a;

            ArgumentsException ex = Assert.Throws <LibraryArgumentException>(() => a = new Arguments(this.marshalers, string.Empty, this.args));

            Assert.Equal(ErrorCode.UNEXPECTED_ARGUMENT, ex.ErrorCode);
            Assert.Equal(this.args[0].Substring(1), ex.ErrorParameter);

            Assert.Equal($"Argument -{string.Empty} unexpected", ex.ErrorMessage());
        }
        public void CreateReferenceAndSetIteratorToLast_FailingTest()
        {
            StringArgumentMarshaler m = new StringArgumentMarshaler();
            Iterator <string>       i = new Iterator <string>(testData);

            for (int j = 0; j < this.testData.Count; j++)
            {
                i.Next();
            }

            ArgumentsException ex = Assert.Throws <StringArgumentMarshaler.StringMarshalerException>(() => m.Set(i));

            ex.ErrorArgumentId = this.testString;

            Assert.Equal(ErrorCode.MISSING, ex.ErrorCode);
            Assert.Equal($"Could not find string parameter for -{this.testString}", ex.ErrorMessage());
        }
示例#3
0
        public void CreateReferenceAndSetIteratorWithWrongFormat_FailingTest()
        {
            IntegerArgumentMarshaler m = new IntegerArgumentMarshaler();
            Iterator <string>        i = new Iterator <string>(testData);

            for (int j = 0; j < (this.testData.Count - 1); j++)
            {
                i.Next();
            }

            ArgumentsException ex = Assert.Throws <IntegerArgumentMarshaler.IntegerMarshalerException>(() => m.Set(i));

            ex.ErrorArgumentId = this.testArgument;

            Assert.Equal(ErrorCode.INVALID, ex.ErrorCode);
            Assert.Equal(this.testArgument, ex.ErrorArgumentId);
            Assert.Equal(this.testData[(this.testData.Count - 1)], ex.ErrorParameter);

            Assert.Equal($"Argument -{this.testArgument} expects an integer but was '{this.testData[(this.testData.Count - 1)]}'", ex.ErrorMessage());
        }
示例#4
0
        public void CreateReferenceAndSetIteratorToOutOfRange_FailingTest()
        {
            IntegerArgumentMarshaler m = new IntegerArgumentMarshaler();
            Iterator <string>        i = new Iterator <string>(testData);

            for (int j = 0; j < this.testData.Count; j++)
            {
                i.Next();
            }

            ArgumentsException ex = Assert.Throws <IntegerArgumentMarshaler.IntegerMarshalerException>(() => m.Set(i));

            ex.ErrorArgumentId = this.testArgument;

            Assert.Equal(ErrorCode.MISSING, ex.ErrorCode);
            Assert.Equal(this.testArgument, ex.ErrorArgumentId);

            Assert.Equal($"Could not find integer parameter for -{this.testArgument}", ex.ErrorMessage());
        }
示例#5
0
        public void CreateReferenceAndSetDirectoryToNull_FailingTest()
        {
            Arguments a;

            ArgumentsException ex = Assert.Throws <LibraryArgumentException>(() => a = new Arguments(null, this.schema, this.args));

            Assert.Equal(ErrorCode.GLOBAL, ex.ErrorCode);
            Assert.Equal($"Marshaler Directory: {string.Empty} not found!", ex.ErrorParameter);

            Assert.Equal($"There was an ERROR with 'Marshaler Directory: {string.Empty} not found!'", ex.ErrorMessage());
        }
示例#6
0
        public void CreateReferenceAndSetArgumentsWithFailingStringParameter_FailingTest()
        {
            Array.Resize(ref this.args, (args.Length - 6));
            string testErrorArgumentId = this.args[(args.Length - 1)].Substring(1);

            Arguments a;

            ArgumentsException ex = Assert.Throws <StringArgumentMarshaler.StringMarshalerException>(() => a = new Arguments(this.marshalers, this.schema, this.args));

            Assert.Equal(ErrorCode.MISSING, ex.ErrorCode);
            Assert.Equal(testErrorArgumentId, ex.ErrorArgumentId);
            Assert.Null(ex.ErrorParameter);

            Assert.Equal($"Could not find string parameter for -{testErrorArgumentId}", ex.ErrorMessage());
        }
示例#7
0
        public void CreateReferenceAndSetArgumentsWithWrongIntegerParameter_FailingTest()
        {
            Array.Resize(ref this.args, (args.Length - 3));
            this.args[(args.Length - 1)] = "NotANumber";

            string testErrorArgumentId = this.args[(args.Length - 2)].Substring(1);

            Arguments a;

            ArgumentsException ex = Assert.Throws <IntegerArgumentMarshaler.IntegerMarshalerException>(() => a = new Arguments(this.marshalers, this.schema, this.args));

            Assert.Equal(ErrorCode.INVALID, ex.ErrorCode);
            Assert.Equal(testErrorArgumentId, ex.ErrorArgumentId);
            Assert.Equal(ex.ErrorParameter, this.args[(args.Length - 1)]);

            Assert.Equal($"Argument -{testErrorArgumentId} expects an integer but was '{this.args[(args.Length - 1)]}'", ex.ErrorMessage());
        }
示例#8
0
        public void CreateReferenceAndSetDirectoryToWrongPath_FailingTest()
        {
            string    wrongPath = @"../";
            Reflector r;

            ArgumentsException ex = Assert.Throws <LibraryArgumentException>(() => r = new Reflector(wrongPath));

            Assert.Equal(ErrorCode.GLOBAL, ex.ErrorCode);
            Assert.Equal($"Marshaler Directory: {wrongPath} does not contain *MarshalerLib.dll files!", ex.ErrorParameter);

            Assert.Equal($"There was an ERROR with 'Marshaler Directory: {wrongPath} does not contain *MarshalerLib.dll files!'", ex.ErrorMessage());
        }
示例#9
0
        public void CreateReferenceAndSetDirectory_FailingTest(string directory)
        {
            Reflector r;

            ArgumentsException ex = Assert.Throws <LibraryArgumentException>(() => r = new Reflector(directory));

            Assert.Equal(ErrorCode.GLOBAL, ex.ErrorCode);
            Assert.Equal($"Marshaler Directory: {string.Empty} not found!", ex.ErrorParameter);

            Assert.Equal($"There was an ERROR with 'Marshaler Directory: {string.Empty} not found!'", ex.ErrorMessage());
        }