public async Task Endpoints_Framework_WebAPI_CustomerDelete()
        {
            var responseData = new Customer();
            var urlCustomer  = new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer");

            try
            {
                await this.Endpoints_Framework_WebAPI_CustomerPut();

                var keyToDelete = Endpoints_Framework_for_WebApi.RecycleBin.Count() > 0 ? Endpoints_Framework_for_WebApi.RecycleBin[0] : Guid.Empty;

                var requestDelete = new HttpRequestDelete(urlCustomer.AddLast("/") + keyToDelete.ToString());
                await requestDelete.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease || requestDelete.Response.IsSuccessStatusCode);

                var requestGet = new HttpRequestGet <Customer>(urlCustomer);
                responseData = await requestGet.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease || responseData != null);
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }
        }
        public void Core_Configuration_ConfigurationManagerCore_ConnectionStrings()
        {
            var itemToTest    = new ConnectionStringSafe();
            var configuration = new ConfigurationManagerCore(ApplicationTypes.Native);

            // Validity
            itemToTest.Value = "Invalid Connection String!!!";
            Assert.IsTrue(itemToTest.IsValid == false);
            // ADO
            itemToTest = configuration.ConnectionString("Example-SQLServer");
            Assert.IsTrue(itemToTest.ToString("EF") != string.Empty);
            Assert.IsTrue(itemToTest.IsADO);
            Assert.IsTrue(itemToTest.IsEF == false);
            Assert.IsTrue(itemToTest.IsValid);
            Assert.IsTrue(itemToTest.ConnectionStringType == ConnectionStringSafe.ConnectionStringTypes.ADO);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != string.Empty);
            // EF
            itemToTest = configuration.ConnectionString("Example-EDMX");
            Assert.IsTrue(itemToTest.ToString("ADO") != string.Empty);
            Assert.IsTrue(itemToTest.IsEF);
            Assert.IsTrue(itemToTest.IsADO == false);
            Assert.IsTrue(itemToTest.IsValid);
            Assert.IsTrue(itemToTest.ConnectionStringType == ConnectionStringSafe.ConnectionStringTypes.EF);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != string.Empty);
            // Specific config entries
            var connectionToTest = new ConnectionStringSafe();

            connectionToTest = configuration.ConnectionString("Example-EDMX");
            Assert.IsTrue(connectionToTest.Value != string.Empty);
            Assert.IsTrue(connectionToTest.IsEF);
            connectionToTest = configuration.ConnectionString("Example-SQLServer");
            Assert.IsTrue(connectionToTest.Value != string.Empty);
            Assert.IsTrue(connectionToTest.IsADO);
        }
        public async Task Endpoints_Framework_WebAPI_CustomerPost()
        {
            var responseData = new Customer();
            var urlCustomer  = new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer");

            await this.Endpoints_Framework_WebAPI_CustomerPut();

            var keyToGet = Endpoints_Framework_for_WebApi.RecycleBin.Count() > 0 ? Endpoints_Framework_for_WebApi.RecycleBin[0] : Guid.Empty;

            try
            {
                var url        = new Uri(urlCustomer.AddLast("/") + keyToGet.ToStringSafe());
                var requestGet = new HttpRequestGet <Customer>(url);
                responseData = await requestGet.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease || responseData != null);

                var testKey = RandomString.Next();
                responseData.FirstName = responseData.FirstName.AddLast(testKey);
                var request = new HttpRequestPost <Customer>(urlCustomer.TryParseUri(), responseData);
                responseData = await request.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease || responseData != null);
                Assert.IsTrue(interfaceBreakingRelease || responseData.FirstName.Contains(testKey));
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }
        }
Esempio n. 4
0
        public void Core_Configuration_ApplicationSettingSafe()
        {
            var itemToTest    = new AppSettingSafe();
            var configuration = new ConfigurationManagerCore(ApplicationTypes.Native);

            itemToTest = configuration.AppSetting("TestAppSetting");
            Assert.IsTrue(itemToTest.Value != string.Empty);
        }
Esempio n. 5
0
        /// <summary>
        /// Can connect to the database?
        /// </summary>
        /// <returns></returns>
        public static bool CanConnect()
        {
            var returnValue   = TypeExtension.DefaultBoolean;
            var configuration = new ConfigurationManagerCore(ApplicationTypes.Native);

            using (var connection = new SqlConnection(configuration.ConnectionStringValue("DefaultConnection")))
            {
                returnValue = connection.CanOpen();
            }
            return(returnValue);
        }
Esempio n. 6
0
        public static void ClassInit(TestContext context)
        {
            // Database is required for these tests
            var databaseAccess = false;
            var configuration  = new ConfigurationManagerCore(ApplicationTypes.Native);

            using (var connection = new SqlConnection(configuration.ConnectionStringValue("DefaultConnection")))
            {
                databaseAccess = connection.CanOpen();
            }
            Assert.IsTrue(databaseAccess);
        }
        public void Core_Configuration_ConfigurationManagerCore_AppSettings()
        {
            // Specific config entries
            var itemToTestString = string.Empty;
            var itemToTest       = new AppSettingSafe();
            var configuration    = new ConfigurationManagerCore(ApplicationTypes.Native);

            itemToTest = configuration.AppSetting("TestAppSetting");
            Assert.IsTrue(itemToTest.Value != string.Empty);
            itemToTestString = configuration.AppSettings.GetValue("TestAppSetting");
            Assert.IsTrue(itemToTestString != string.Empty);
        }
Esempio n. 8
0
        public void Data_ConnectionStringDatabase()
        {
            var configManager       = new ConfigurationManagerCore(ApplicationTypes.Native);
            var configConnectString = configManager.ConnectionString(this.GetAttributeValue <ConnectionStringName>(ConnectionStringName.DefaultConnectionName));
            var result = configConnectString.ToEF(typeof(EntityWithConnectString));

            Assert.IsTrue(result != Defaults.String);
            Assert.IsTrue(configConnectString.IsValid);
            Assert.IsTrue(configConnectString.IsEF || configConnectString.IsADO);
            Assert.IsTrue(configConnectString.ConnectionStringType != ConnectionStringSafe.ConnectionStringTypes.Empty &&
                          configConnectString.ConnectionStringType != ConnectionStringSafe.ConnectionStringTypes.Invalid);
        }
        public void Core_Configuration_ConnectionStringSafe()
        {
            var itemToTest    = new ConnectionStringSafe();
            var configuration = new ConfigurationManagerCore(ApplicationTypes.Native);

            // ADO
            itemToTest = configuration.ConnectionString("Example-SQLServer");
            Assert.IsTrue(itemToTest.Value != string.Empty);
            itemToTest.EDMXFileName = "TestEDMXFile";
            Assert.IsTrue(itemToTest.ToString("EF") != string.Empty);
            Assert.IsTrue(itemToTest.ToEF(this.GetType()) != string.Empty);
            // EF
            itemToTest = configuration.ConnectionString("Example-EDMX");
            Assert.IsTrue(itemToTest.Value != string.Empty);
            Assert.IsTrue(itemToTest.ToString("ADO") != string.Empty);
            Assert.IsTrue(itemToTest.ToADO() != string.Empty);
        }
Esempio n. 10
0
        /// <summary>
        /// Removes EF code-first migration history table
        /// </summary>
        /// <param name="database"></param>
        /// <param name="schema"></param>
        public static void DropMigrationHistory(string database = "[FrameworkData]", string schema = "[Activity]")
        {
            // Must remove __MigrationHistory for EF Code First objects to auto-create their tables
            var configuration = new ConfigurationManagerCore(ApplicationTypes.Native);

            try
            {
                using (var connection = new SqlConnection(configuration.ConnectionStringValue("DefaultConnection")))
                {
                    using (var command = new SqlCommand("Drop Table " + database + "." + schema + ".[__MigrationHistory]", connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (SqlException)
            {
                // Ignore connection errors
            }
        }
Esempio n. 11
0
        public async Task Core_Net_HttpRequestGet_SendAsync()
        {
            var    configuration = new ConfigurationManagerCore(ApplicationTypes.Native);
            object dataOut       = null;
            var    request       = new HttpRequestGet <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi");

            try
            {
                dataOut = await request.SendAsync();

                Assert.IsTrue(request.Response.IsSuccessStatusCode);
                throw new HttpRequestException();
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(dataOut != null || ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }
            finally
            {
                request.Dispose();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Loads config data
        /// </summary>
        /// <returns></returns>
        public async Task LoadDataAsync()
        {
            await Task.Delay(1);

            ConfigurationManager = new ConfigurationManagerCore(ApplicationTypes.Native);
        }