Ejemplo n.º 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());
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
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());
        }
Ejemplo n.º 9
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());
        }
Ejemplo n.º 10
0
        public void ConstructorInitializesMessageWithWithMessageAndDelimitedListOfParameterNames()
        {
            var exception = new ArgumentsException("test", "param1", "param2", "param3");

            exception.Message.Should().BeEquivalentTo("test (Parameters 'param1', 'param2', 'param3')");
        }
Ejemplo n.º 11
0
        public void ConstructorInitializesParamNameWithDelimitedListOfParameterNames()
        {
            var exception = new ArgumentsException(string.Empty, "param1", "param2", "param3");

            exception.ParamName.Should().BeEquivalentTo("param1, param2, param3");
        }
Ejemplo n.º 12
0
        public void ConstructorInitializesParamNamesWithParameterNamesArgument()
        {
            var exception = new ArgumentsException(string.Empty, "param1", "param2", "param3");

            exception.ParamNames.Should().BeEquivalentTo("param1", "param2", "param3");
        }