public void Create_uses_given_message_inner_exception_and_error_context_and_sets_up_serialization()
        {
            var innerException = new Exception("Ho Ho Ho");
            var exception      = EntitySqlException.Create(
                new ErrorContext
            {
                CommandText      = "select redHook\n from\n breweries",
                ErrorContextInfo = "Hubcap emotional barometer is peaking",
                InputPosition    = 22,
                UseContextInfoAsResourceIdentifier = false
            },
                "Why not use LINQ like everyone else?",
                innerException);

            Assert.Equal(
                "Why not use LINQ like everyone else? Near Hubcap emotional barometer is peaking, line 3, column 2.", exception.Message);
            Assert.Same(innerException, exception.InnerException);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("Hubcap emotional barometer is peaking, line 3, column 2", exception.ErrorContext);
            Assert.Equal("Why not use LINQ like everyone else?", exception.ErrorDescription);
            Assert.Equal(3, exception.Line);
            Assert.Equal(2, exception.Column);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal(
                "Why not use LINQ like everyone else? Near Hubcap emotional barometer is peaking, line 3, column 2.", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("Hubcap emotional barometer is peaking, line 3, column 2", exception.ErrorContext);
            Assert.Equal("Why not use LINQ like everyone else?", exception.ErrorDescription);
            Assert.Equal(3, exception.Line);
            Assert.Equal(2, exception.Column);
        }
        public void PropertyConstraintException_with_null_property_name_can_be_serialized_and_deserialized()
        {
            var ex = ExceptionHelpers.SerializeAndDeserialize(new PropertyConstraintException());

            Assert.Null(ex.PropertyName);
            Assert.Null(ex.InnerException);
        }
        public void Create_allows_all_state_to_be_set_and_sets_up_serialization()
        {
            var innerException = new Exception("Green Giant");
            var exception      = EntitySqlException.Create(
                commandText: "select brandy\n from\n spirits",
                errorDescription: "This isn't the vodka I ordered.",
                errorPosition: 17,
                errorContextInfo: "It's Polish plum brandy, dude!",
                loadErrorContextInfoFromResource: true,
                innerException: innerException);

            Assert.Equal("This isn't the vodka I ordered. Near line 2, column 4.", exception.Message);
            Assert.Same(innerException, exception.InnerException);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("line 2, column 4", exception.ErrorContext);
            Assert.Equal("This isn't the vodka I ordered.", exception.ErrorDescription);
            Assert.Equal(2, exception.Line);
            Assert.Equal(4, exception.Column);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("This isn't the vodka I ordered. Near line 2, column 4.", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("line 2, column 4", exception.ErrorContext);
            Assert.Equal("This isn't the vodka I ordered.", exception.ErrorDescription);
            Assert.Equal(2, exception.Line);
            Assert.Equal(4, exception.Column);
        }
 [Fact] // CodePlex 1107
 public void Deserialized_exception_can_be_serialized_and_deserialized_again()
 {
     Assert.Equal(
         "But somehow the vital connection is made",
         ExceptionHelpers.SerializeAndDeserialize(
             ExceptionHelpers.SerializeAndDeserialize(
                 new DbUpdateException("But somehow the vital connection is made"))).Message);
 }
 [Fact] // CodePlex 1107
 public void Deserialized_exception_can_be_serialized_and_deserialized_again()
 {
     Assert.Equal(
         "Roundabout and roundabout",
         ExceptionHelpers.SerializeAndDeserialize(
             ExceptionHelpers.SerializeAndDeserialize(
                 new DbEntityValidationException("Roundabout and roundabout"))).Message);
 }
Exemplo n.º 6
0
 [Fact] // CodePlex 1107
 public void Deserialized_exception_can_be_serialized_and_deserialized_again()
 {
     Assert.Equal(
         "Riding on any wave",
         ExceptionHelpers.SerializeAndDeserialize(
             ExceptionHelpers.SerializeAndDeserialize(
                 new DbUpdateConcurrencyException("Riding on any wave"))).Message);
 }
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var exception = ExceptionHelpers.SerializeAndDeserialize(
                ExceptionHelpers.SerializeAndDeserialize(
                    new EntitySqlException("What is this eSQL of which you speak?")));

            Assert.Equal("What is this eSQL of which you speak?", exception.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
        }
        public void PropertyConstraintException_with_non_null_property_name_can_be_serialized_and_deserialized()
        {
            var ex =
                ExceptionHelpers.SerializeAndDeserialize(
                    new PropertyConstraintException("Message", "Property", new InvalidOperationException("Inner")));

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);
            Assert.Equal("Inner", ex.InnerException.Message);
        }
Exemplo n.º 9
0
        public void PropertyConstraintException_exposes_public_empty_constructor()
        {
            var ex = new PropertyConstraintException();

            Assert.Null(ex.PropertyName);

            ex = ExceptionHelpers.SerializeAndDeserialize(ex);

            Assert.Null(ex.PropertyName);
        }
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var inner = new Exception("The cracks of doom!");
            var ex    = new PropertyConstraintException("Message", "Property", inner);

            ex = ExceptionHelpers.SerializeAndDeserialize(ExceptionHelpers.SerializeAndDeserialize(ex));

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);
            Assert.Equal(inner.Message, ex.InnerException.Message);
        }
Exemplo n.º 11
0
        public void Constructor_uses_given_message_and_sets_up_serialization()
        {
            var exception = new migrate::CmdLine.CommandLineException("I'm a DOS prompt.");

            Assert.Equal("I'm a DOS prompt.", exception.Message);
            Assert.Null(exception.ArgumentHelp);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("I'm a DOS prompt.", exception.Message);
            Assert.Null(exception.ArgumentHelp);
        }
Exemplo n.º 12
0
        public void PropertyConstraintException_exposes_public_string_and_property_name_constructor()
        {
            var ex = new PropertyConstraintException("Message", "Property");

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);

            ex = ExceptionHelpers.SerializeAndDeserialize(ex);

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);
        }
Exemplo n.º 13
0
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var innerException = new Exception("You are so exceptional!");
            var exception      =
                new migrate::CmdLine.CommandLineException(
                    new migrate::CmdLine.CommandArgumentHelp(typeof(SomeCommandLineClass), "Look inside."), innerException);

            exception = ExceptionHelpers.SerializeAndDeserialize(ExceptionHelpers.SerializeAndDeserialize(exception));

            Assert.Equal("Look inside.", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Equal("Code First Migrations Command Line Utility", exception.ArgumentHelp.Title);
        }
Exemplo n.º 14
0
        public void Constructor_uses_given_ArgumentHelp_and_sets_up_serialization()
        {
            var exception =
                new migrate::CmdLine.CommandLineException(
                    new migrate::CmdLine.CommandArgumentHelp(typeof(SomeCommandLineClass), "CLI"));

            Assert.Equal("CLI", exception.Message);
            Assert.Equal("Code First Migrations Command Line Utility", exception.ArgumentHelp.Title);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("CLI", exception.Message);
            Assert.Equal("Code First Migrations Command Line Utility", exception.ArgumentHelp.Title);
        }
        public void Constructor_uses_given_message_and_sets_up_serialization()
        {
            var exception = new ToolingException("It's Tool Time!");

            Assert.Equal("It's Tool Time!", exception.Message);
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("It's Tool Time!", exception.Message);
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);
        }
        public void Constructor_uses_given_detailed_information_and_sets_up_serialization()
        {
            var exception = new ToolingException("Really?", "INTP", "Where's my tracing paper?");

            Assert.Equal("Really?", exception.Message);
            Assert.Equal("INTP", exception.InnerType);
            Assert.Equal("Where's my tracing paper?", exception.InnerStackTrace);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("Really?", exception.Message);
            Assert.Equal("INTP", exception.InnerType);
            Assert.Equal("Where's my tracing paper?", exception.InnerStackTrace);
        }
        public void Parameterless_constructor_uses_default_message_and_sets_up_serialization()
        {
            var exception = new ToolingException();

            Assert.True(exception.Message.Contains("'System.Data.Entity.Migrations.Design.ToolingException'"));
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.True(exception.Message.Contains("'System.Data.Entity.Migrations.Design.ToolingException'"));
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);
        }
Exemplo n.º 18
0
        public void PropertyConstraintException_exposes_public_string_and_inner_exception_constructor()
        {
            var inner = new Exception("Don't look down.");
            var ex    = new PropertyConstraintException("Message", inner);

            Assert.Equal("Message", ex.Message);
            Assert.Same(inner, ex.InnerException);
            Assert.Null(ex.PropertyName);

            ex = ExceptionHelpers.SerializeAndDeserialize(ex);

            Assert.Equal("Message", ex.Message);
            Assert.Equal(inner.Message, ex.InnerException.Message);
            Assert.Null(ex.PropertyName);
        }
Exemplo n.º 19
0
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var commandArg = new migrate::CmdLine.CommandArgument("/N:345", 7);

            commandArg.Command = "N";

            var ex = new migrate::CmdLine.CommandLineRequiredArgumentMissingException(
                typeof(CommandLineExceptionTests.SomeCommandLineClass), "/N:345", 7);

            Assert.Contains("/N:345", ex.Message);

            Assert.Contains(
                "/N:345",
                ExceptionHelpers.SerializeAndDeserialize(ExceptionHelpers.SerializeAndDeserialize(ex)).Message);
        }
Exemplo n.º 20
0
        public void PropertyConstraintException_exposes_public_string_property_name_and_inner_exception_constructor()
        {
            var inner = new Exception("The cracks of doom!");
            var ex    = new PropertyConstraintException("Message", "Property", inner);

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);
            Assert.Same(inner, ex.InnerException);

            ex = ExceptionHelpers.SerializeAndDeserialize(ex);

            Assert.Equal("Message", ex.Message);
            Assert.Equal("Property", ex.PropertyName);
            Assert.Equal(inner.Message, ex.InnerException.Message);
        }
        public void Constructor_uses_given_message_and_inner_exception_and_sets_up_serialization()
        {
            var innerException = new Exception("Hello? Hello?");
            var exception      = new ToolingException("Can somebody let me out?", innerException);

            Assert.Equal("Can somebody let me out?", exception.Message);
            Assert.Same(innerException, exception.InnerException);
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("Can somebody let me out?", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Null(exception.InnerType);
            Assert.Null(exception.InnerStackTrace);
        }
Exemplo n.º 22
0
        public void Constructor_uses_given_ArgumentHelp_and_inner_exception_and_sets_up_serialization()
        {
            var innerException = new Exception("You are so exceptional!");
            var exception      =
                new migrate::CmdLine.CommandLineException(
                    new migrate::CmdLine.CommandArgumentHelp(typeof(SomeCommandLineClass), "Look inside."), innerException);

            Assert.Equal("Look inside.", exception.Message);
            Assert.Same(innerException, exception.InnerException);
            Assert.Equal("Code First Migrations Command Line Utility", exception.ArgumentHelp.Title);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("Look inside.", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Equal("Code First Migrations Command Line Utility", exception.ArgumentHelp.Title);
        }
        public void Parameterless_constructor_uses_general_message_and_sets_up_serialization()
        {
            var exception = new EntitySqlException();

            Assert.Equal(Strings.GeneralQueryError, exception.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal(Strings.GeneralQueryError, exception.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);
        }
        public void Constructor_uses_given_message_and_sets_up_serialization()
        {
            var exception = new EntitySqlException("What is this eSQL of which you speak?");

            Assert.Equal("What is this eSQL of which you speak?", exception.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("What is this eSQL of which you speak?", exception.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);
        }
        public void Constructor_uses_given_message_and_inner_exception_and_sets_up_serialization()
        {
            var innerException = new Exception("I'm in here.");
            var exception      = new EntitySqlException("I knoweth not, good sir.", innerException);

            Assert.Equal("I knoweth not, good sir.", exception.Message);
            Assert.Same(innerException, exception.InnerException);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);

            exception = ExceptionHelpers.SerializeAndDeserialize(exception);

            Assert.Equal("I knoweth not, good sir.", exception.Message);
            Assert.Equal(innerException.Message, exception.InnerException.Message);
            Assert.Equal(HResultInvalidQuery, GetHResult(exception));
            Assert.Equal("", exception.ErrorContext);
            Assert.Equal("", exception.ErrorDescription);
            Assert.Equal(0, exception.Line);
            Assert.Equal(0, exception.Column);
        }