Esempio n. 1
0
        public void TestInvalidCultureName2()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("aNameOfAParam", "abcd", "this is a test string");

            Assert.Equal("this is a test string\r\nParameter name: aNameOfAParam\r\nabcd is an invalid culture identifier.", cnf.Message);
            Assert.Equal("abcd", cnf.InvalidCultureName);
        }
        public void Ctor_String()
        {
            string message = "this is a test string";
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(message);

            Assert.Equal(message, cultureNotFoundException.Message);
        }
        public void Ctor_String()
        {
            string message = "this is a test string";
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(message);

            Assert.Equal(message, cultureNotFoundException.Message);
        }
        public void TestInvalidCultureName2()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("aNameOfAParam", "abcd", "this is a test string");

            Assert.Equal("this is a test string" + System.Environment.NewLine + "Parameter name: aNameOfAParam" + System.Environment.NewLine + "abcd is an invalid culture identifier.", cnf.Message);
            Assert.Equal("abcd", cnf.InvalidCultureName);
        }
        public void TestInnerExceptionMessage()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("this is a test string", new Exception("inner exception string"));

            Assert.Equal("this is a test string", cnf.Message);
            Assert.Equal("inner exception string", cnf.InnerException.Message);
        }
        public void TypePropertiesAreCorrect()
        {
            Assert.AreEqual("System.Globalization.CultureNotFoundException", typeof(CultureNotFoundException).GetClassName(), "Name");
            object d = new CultureNotFoundException();

            Assert.True(d is CultureNotFoundException);
            Assert.True(d is Exception);
        }
        public void TypePropertiesAreCorrect()
        {
            Assert.AreEqual(typeof(CultureNotFoundException).GetClassName(), "Bridge.CultureNotFoundException", "Name");
            object d = new CultureNotFoundException();

            Assert.True(d is CultureNotFoundException);
            Assert.True(d is Exception);
        }
        public void TestInvalidCultureName1()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("this is a test string", "abcd", new Exception("inner exception string"));

            Assert.Equal("this is a test string" + System.Environment.NewLine + "abcd is an invalid culture identifier.", cnf.Message);
            Assert.Equal("inner exception string", cnf.InnerException.Message);
            Assert.Equal("abcd", cnf.InvalidCultureName);
        }
        public void Ctor_String_String()
        {
            string paramName = "nameOfParam";
            string message = "this is a test string";
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(paramName, message);

            Assert.Equal(paramName, cultureNotFoundException.ParamName);
            Assert.NotEmpty(cultureNotFoundException.Message);
        }
        public void Ctor_String_Exception()
        {
            string message = "this is a test string";
            Exception innerException = new Exception("inner exception string");
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(message, innerException);

            Assert.Equal(message, cultureNotFoundException.Message);
            Assert.Same(innerException, cultureNotFoundException.InnerException);
        }
        public void DefaultConstructorWorks()
        {
            var ex = new CultureNotFoundException();

            Assert.True((object)ex is CultureNotFoundException, "is CultureNotFoundException");
            Assert.AreEqual(null, ex.ParamName, "ParamName");
            Assert.AreEqual(null, ex.InnerException, "InnerException");
            Assert.AreEqual(DefaultMessage, ex.Message);
        }
        public void Ctor_String_String()
        {
            string paramName = "nameOfParam";
            string message   = "this is a test string";
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(paramName, message);

            Assert.Equal(paramName, cultureNotFoundException.ParamName);
            Assert.NotEmpty(cultureNotFoundException.Message);
        }
        public void Ctor_String_Exception()
        {
            string    message        = "this is a test string";
            Exception innerException = new Exception("inner exception string");
            CultureNotFoundException cultureNotFoundException = new CultureNotFoundException(message, innerException);

            Assert.Equal(message, cultureNotFoundException.Message);
            Assert.Same(innerException, cultureNotFoundException.InnerException);
        }
        public void ConstructorWithParamNameAndCultureNameAndMessage()
        {
            var ex = new CultureNotFoundException("SomeParam", "fru", "The message");

            Assert.True((object)ex is CultureNotFoundException, "is CultureNotFoundException");
            Assert.AreEqual("SomeParam", ex.ParamName, "ParamName");
            Assert.Null(ex.InnerException, "InnerException");
            Assert.AreEqual("The message", ex.Message);
            Assert.AreEqual("fru", ex.InvalidCultureName, "InvalidCultureName");
            Assert.AreEqual(null, ex.InvalidCultureId, "InvalidCultureId");
        }
        public void ConstructorWithMessageAndParamNameWorks()
        {
            var ex = new CultureNotFoundException("someParam", "The message");

            Assert.True((object)ex is CultureNotFoundException, "is CultureNotFoundException");
            Assert.AreEqual(ex.ParamName, "someParam", "ParamName");
            Assert.AreEqual(ex.InnerException, null, "InnerException");
            Assert.AreEqual(ex.Message, "The message");
            Assert.AreEqual(ex.InvalidCultureName, null, "InvalidCultureName");
            Assert.AreEqual(ex.InvalidCultureId, null, "InvalidCultureId");
        }
        public void ConstructorWithMessageAndInnerExceptionWorks()
        {
            var inner = new Exception("a");
            var ex    = new CultureNotFoundException("The message", inner);

            Assert.True((object)ex is CultureNotFoundException, "is CultureNotFoundException");
            Assert.AreEqual(null, ex.ParamName, "ParamName");
            Assert.AreEqual(inner, ex.InnerException, "InnerException");
            Assert.AreEqual("The message", ex.Message);
            Assert.AreEqual(null, ex.InvalidCultureName, "InvalidCultureName");
            Assert.AreEqual(null, ex.InvalidCultureId, "InvalidCultureId");
        }
Esempio n. 17
0
        public void CultureNotFoundExceptionTest()
        {
            AssertExtensions.Throws <CultureNotFoundException>("name", () => new CultureInfo("!@#$%^&*()"));
            AssertExtensions.Throws <CultureNotFoundException>("name", () => new CultureInfo("This is invalid culture"));
            AssertExtensions.Throws <CultureNotFoundException>("name", () => new CultureInfo("longCulture" + new string('a', 100)));
            AssertExtensions.Throws <CultureNotFoundException>("culture", () => new CultureInfo(0x1000));

            CultureNotFoundException e = AssertExtensions.Throws <CultureNotFoundException>("name", () => new CultureInfo("This is invalid culture"));

            Assert.Equal("This is invalid culture", e.InvalidCultureName);

            e = AssertExtensions.Throws <CultureNotFoundException>("culture", () => new CultureInfo(0x1000));
            Assert.Equal(0x1000, e.InvalidCultureId);
        }
Esempio n. 18
0
        private CultureInfo GetCultureInfoByChecking(string name)
        {
            CultureInfo cultureInfo;

            try
            {
                cultureInfo = CultureInfo.GetCultureInfo(name);
            }
            catch (CultureNotFoundException cultureNotFoundException1)
            {
                CultureNotFoundException cultureNotFoundException = cultureNotFoundException1;
                base.Logger.Warn(cultureNotFoundException.ToString(), cultureNotFoundException);
                throw new UserFriendlyException(this.L("InvlalidLanguageCode"));
            }
            return(cultureInfo);
        }
Esempio n. 19
0
        public IActionResult ReturnNotFoundError()
        {
            var ex = new CultureNotFoundException("Bez kultur net multur.");

            return(this.NotFoundError(ex));
        }
        public void TestMessage()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("this is a test string");

            Assert.Equal("this is a test string", cnf.Message);
        }
Esempio n. 21
0
        public void TestParamName()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("aNameOfAParam", "this is a test string");

            Assert.Equal("this is a test string\r\nParameter name: aNameOfAParam", cnf.Message);
        }
        public void TestParamName()
        {
            CultureNotFoundException cnf = new CultureNotFoundException("aNameOfAParam", "this is a test string");

            Assert.Equal("this is a test string" + System.Environment.NewLine + "Parameter name: aNameOfAParam", cnf.Message);
        }