Пример #1
0
        public void ToStringTest()
        {
            UsingConfiguration usingConfiguration = new UsingConfiguration();

            usingConfiguration.MoveTo = CodeLevel.File;

            string str = usingConfiguration.ToString();

            Assert.AreEqual("Usings: MoveTo - File", str, "Unexpected string representation.");
        }
Пример #2
0
        public void CreateTest()
        {
            UsingConfiguration usingConfiguration = new UsingConfiguration();

            //
            // Verify default state
            //
            Assert.AreEqual(
                CodeLevel.None,
                usingConfiguration.MoveTo,
                "Unexpected default value for MoveTo.");
        }
Пример #3
0
        public void CloneTest()
        {
            UsingConfiguration usingConfiguration = new UsingConfiguration();

            usingConfiguration.MoveTo = CodeLevel.Namespace;

            UsingConfiguration clone = usingConfiguration.Clone() as UsingConfiguration;

            Assert.IsNotNull(clone, "Clone did not return a valid instance.");

            Assert.AreEqual(
                usingConfiguration.MoveTo,
                clone.MoveTo);
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Config Sample");

            // Define user selection string.
            string selection;

            // Get the name of the application.
            string appName =
                Environment.GetCommandLineArgs()[0];

            // Get user selection.
            while (true)
            {
                UserMenu();
                Console.Write("> ");
                selection = Console.ReadLine();
                if (!string.IsNullOrEmpty(selection))
                {
                    break;
                }
            }

            while (selection.ToLower() != "q")
            {
                // Process user's input.
                switch (selection)
                {
                case "1":
                    // Show how to create an instance of the Configuration class.
                    UsingConfiguration.CreateConfigurationFile();
                    break;

                case "2":
                    // Show how to use GetSection(string) method.
                    UsingConfiguration.GetCustomSection();
                    break;

                case "3":
                    // Show how to use ConnectionStrings.
                    UsingConfiguration.SaveConfigurationFile();
                    break;

                case "4":
                    // Show how to use the AppSettings property.
                    UsingConfiguration.GetSections("appSettings");
                    break;

                case "5":
                    // Show how to use the ConnectionStrings property.
                    UsingConfiguration.GetSections("connectionStrings");
                    break;

                case "6":
                    // Show how to obtain configuration file information.
                    UsingConfiguration.GetConfigurationInformation();
                    break;

                default:
                    UserMenu();
                    break;
                }
                Console.Write("> ");
                selection = Console.ReadLine();
            }

            //Console.Read();
        }