Camino / src / Empi.Camino.Test / SettingsTest.cs

using Empi.Camino.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
using System;

namespace Empi.Camino.Test
{


	/// <summary>
	///This is a test class for SettingsTest and is intended
	///to contain all SettingsTest Unit Tests
	///</summary>
	[TestClass()]
	public class SettingsTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion

        private class TestSettings : Empi.Camino.Configuration.Settings
        {
         
            internal static TestSettings GetTestSettings
            {
                get
                {
                    return GetSettings<TestSettings>();
                }
            }

            protected override System.Type SettingsTableType
            {
                get
                {
                    return typeof(Empi.Camino.Data.Retailer.Common_Settings);
                }
            }


            [CaminoSetting("Retailer-Dummytest")]
            [DefaultSettingValue("dummyValue")]
            [System.ComponentModel.ReadOnly(true)]
            [SettingsSerializeAsAttribute(SettingsSerializeAs.String)]
            [Fake]
            internal string Dummytest
            {
                get { return (string)this["Retailer-Dummytest"]; }
                set { this["Retailer-Dummytest"] = value; }
            }
        } 
        
        [AttributeUsage(AttributeTargets.Property)]
        private class FakeAttribute: Attribute
        {}


		[TestMethod()]
		[Description("Test that the Test ID comes back.")]
		[DeploymentItem("Empi.Camino.dll")]
		public void MyDbIdTest()
		{
            string actual = TestSettings.GetTestSettings.MyDbId;
			Assert.AreEqual<string>("dev", actual);
		}

		[TestMethod()]
		[Description("Test that the Test MetaDataBaseConnectionString comes back.")]
		[DeploymentItem("Empi.Camino.dll")]
		public void MetaDataBaseConnectionStringTest()
		{
            string actual = TestSettings.GetTestSettings.MetaDataBaseConnectionString;
			Assert.AreEqual<string>(@"Data Source=MPODONYI-PC\SQLEXPRESS;Initial Catalog=MetaDb;Integrated Security=True", actual);
		}

        [TestMethod()]
        [DeploymentItem("Empi.Camino.dll")]
        public void MyDbStateTest()
        {
            string actual = TestSettings.GetTestSettings.MyDbState;
            Assert.AreEqual<string>("dev", actual);
        }

        [TestMethod()]
        [DeploymentItem("Empi.Camino.dll")]
        public void EnableCacheTest()
        {
            Assert.IsTrue(TestSettings.GetTestSettings.EnableCache);

            TestSettings.GetTestSettings.EnableCache = false;

            Assert.IsFalse(TestSettings.GetTestSettings.EnableCache);

            TestSettings.GetTestSettings.EnableCache = true;

            Assert.IsTrue(TestSettings.GetTestSettings.EnableCache);
        }


        [TestMethod()]
        [DeploymentItem("Empi.Camino.dll")]
        public void SettingsPropertyDiscoveryTest()
        {
            TestSettings actual = TestSettings.GetTestSettings;

            SettingsProperty testProperty = actual.Properties["Retailer-Dummytest"];

            Assert.IsNotNull(testProperty);

            Assert.IsTrue(testProperty.IsReadOnly);

            Assert.AreEqual(testProperty.DefaultValue, "dummyValue");

            Assert.AreEqual(testProperty.Name, "Retailer-Dummytest");

            Assert.AreEqual(typeof(string), testProperty.PropertyType);

            Assert.IsTrue(testProperty.ThrowOnErrorDeserializing);

            Assert.IsTrue(testProperty.ThrowOnErrorSerializing);

            Assert.AreEqual(testProperty.SerializeAs, SettingsSerializeAs.String);

            Assert.IsInstanceOfType(testProperty.Provider, typeof(CaminoSettingsProvider));

            Assert.IsInstanceOfType(testProperty.Attributes[typeof(FakeAttribute)], typeof(FakeAttribute));


            //MP: more Tests here
        }

	}
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.