コード例 #1
0
        public void Configuration_ConfigurationManagerSafe_ConnectionStrings()
        {
            var itemToTest    = new ConnectionStringSafe();
            var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();

            // Validity
            itemToTest.Value = "Invalid Connection String!!!";
            Assert.IsTrue(itemToTest.IsValid == false);
            // ADO
            itemToTest = configuration.ConnectionString("TestADOConnection");
            Assert.IsTrue(itemToTest.ToString("EF") != TypeExtension.DefaultString);
            Assert.IsTrue(itemToTest.IsADO == true);
            Assert.IsTrue(itemToTest.IsEF == false);
            Assert.IsTrue(itemToTest.IsValid == true);
            Assert.IsTrue(itemToTest.ConnectionStringType == ConnectionStringSafe.ConnectionStringTypes.ADO);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != TypeExtension.DefaultString);
            // EF
            itemToTest = configuration.ConnectionString("TestEFConnection");
            Assert.IsTrue(itemToTest.ToString("ADO") != TypeExtension.DefaultString);
            Assert.IsTrue(itemToTest.IsEF == true);
            Assert.IsTrue(itemToTest.IsADO == false);
            Assert.IsTrue(itemToTest.IsValid == true);
            Assert.IsTrue(itemToTest.ConnectionStringType == ConnectionStringSafe.ConnectionStringTypes.EF);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != TypeExtension.DefaultString);
        }
コード例 #2
0
        public void Configuration_ConfigurationManagerSafe_AppSettings()
        {
            var itemToTest    = new AppSettingSafe();
            var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();

            itemToTest = configuration.AppSetting("TestAppSetting");
            Assert.IsTrue(itemToTest.Value != TypeExtension.DefaultString);
        }
コード例 #3
0
        public void Configuration_ConnectionStringSafe()
        {
            var itemToTest    = new ConnectionStringSafe();
            var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();

            // ADO
            itemToTest = configuration.ConnectionString("TestADOConnection");
            Assert.IsTrue(itemToTest.Value != TypeExtension.DefaultString);
            itemToTest.EDMXFileName = "TestEDMXFile";
            Assert.IsTrue(itemToTest.ToString("EF") != TypeExtension.DefaultString);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != TypeExtension.DefaultString);
            // EF
            itemToTest = configuration.ConnectionString("TestEFConnection");
            Assert.IsTrue(itemToTest.Value != TypeExtension.DefaultString);
            Assert.IsTrue(itemToTest.ToString("ADO") != TypeExtension.DefaultString);
            Assert.IsTrue(itemToTest.ToADO() != TypeExtension.DefaultString);
        }
コード例 #4
0
        public async Task Net_HttpRequestDelete_SendAsync()
        {
            object dataOut       = null;
            var    configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();
            var    request       = new HttpRequestDelete <object>(configuration.AppSettingValue(AppSettingList.MyWebServiceKeyName) + "/HomeApi");

            try
            {
                dataOut = await request.SendAsync();

                Assert.IsTrue(request.Response.IsSuccessStatusCode);
            }
            catch (WebException)
            {
                Assert.IsTrue(dataOut != null);
            }
            finally
            {
                request.Dispose();
            }
        }
コード例 #5
0
        public async Task Net_HttpRequestPutString_SendAsync()
        {
            var dataOut       = TypeExtension.DefaultString;
            var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();
            var request       = new HttpRequestPutString(configuration.AppSettingValue("MyWebService") + "/HomeApi");

            try
            {
                dataOut = await request.SendAsync();

                Assert.IsTrue(request.Response.IsSuccessStatusCode);
                throw new WebException();
            }
            catch (WebException)
            {
                Assert.IsTrue(dataOut != null);
            }
            finally
            {
                request.Dispose();
            }
        }
コード例 #6
0
 /// <summary>
 /// Constructs a current instance of .config AppSettings and ConnectionStrings nodes
 /// Universal/Core does not support ConfigurationManager, so have to construct using Universal friendly means
 /// </summary>
 /// <returns></returns>
 public static ConfigurationManagerSafe ConfigurationManagerSafeConstruct()
 {
     return(new ConfigurationManagerSafe(ConfigurationManagerSafeTests.AppSettingsGet(), ConfigurationManagerSafeTests.ConnectionStringsGet()));
 }