Example #1
0
        public void TestFixtureSetUp()
        {
            if (_dummyCulture == null)
            {
                throw new Exception("Error setting up test - dummyCulture should not be NULL");
            }
            if (CultureInfo.InvariantCulture.Equals(_dummyCulture))
            {
                throw new Exception("Error setting up test - dummyCulture should not be invariant");
            }
            if (_dummyCulture2 == null)
            {
                throw new Exception("Error setting up test - dummyCulture2 should not be NULL");
            }
            if (CultureInfo.InvariantCulture.Equals(_dummyCulture2))
            {
                throw new Exception("Error setting up test - dummyCulture2 should not be invariant");
            }
            if (_dummyCulture2.Equals(_dummyCulture))
            {
                throw new Exception("Error setting up test - dummyCulture2 should not be the same as dummyCulture");
            }

            // for testing purposes, set up the converter for a specific culture to have the Enum.ToString() mapping
            // normally, you would use TypeDescriptor.GetConverter, but we want to keep the test appdomain clean of these testing mods
            ModifierFlagsConverter converter = new ModifierFlagsConverter(_dummyCulture);
            IDictionary <ModifierFlags, string> relocalizedNames = new Dictionary <ModifierFlags, string>();

            foreach (KeyValuePair <ModifierFlags, string> pair in converter.LocalizedNames)
            {
                relocalizedNames.Add(pair.Key, Enum.GetName(typeof(ModifierFlags), pair.Key));
            }
            relocalizedNames[ModifierFlags.Shift] = ModifierFlagsConverter.ModifierSeparator.ToString();
            converter.LocalizedNames = relocalizedNames;

            _converter = converter;
        }
		public void TestFixtureSetUp()
		{
			if (_dummyCulture == null)
				throw new Exception("Error setting up test - dummyCulture should not be NULL");
			if (CultureInfo.InvariantCulture.Equals(_dummyCulture))
				throw new Exception("Error setting up test - dummyCulture should not be invariant");
			if (_dummyCulture2 == null)
				throw new Exception("Error setting up test - dummyCulture2 should not be NULL");
			if (CultureInfo.InvariantCulture.Equals(_dummyCulture2))
				throw new Exception("Error setting up test - dummyCulture2 should not be invariant");
			if (_dummyCulture2.Equals(_dummyCulture))
				throw new Exception("Error setting up test - dummyCulture2 should not be the same as dummyCulture");

			// for testing purposes, set up the converter for a specific culture to have the Enum.ToString() mapping
			// normally, you would use TypeDescriptor.GetConverter, but we want to keep the test appdomain clean of these testing mods
			ModifierFlagsConverter converter = new ModifierFlagsConverter(_dummyCulture);
			IDictionary<ModifierFlags, string> relocalizedNames = new Dictionary<ModifierFlags, string>();
			foreach (KeyValuePair<ModifierFlags, string> pair in converter.LocalizedNames)
				relocalizedNames.Add(pair.Key, Enum.GetName(typeof (ModifierFlags), pair.Key));
			relocalizedNames[ModifierFlags.Shift] = ModifierFlagsConverter.ModifierSeparator.ToString();
			converter.LocalizedNames = relocalizedNames;

			_converter = converter;
		}