Example #1
0
        internal static ClientType DbToCommon(this DbClientType dbClientType)
        {
            ClientType clientType = new ClientType()
            {
                Id          = dbClientType.Id,
                MinutePrice = dbClientType.MinutePrice,
                SMSPrice    = dbClientType.SMSPrice,
                TypeName    = dbClientType.TypeName
            };

            return(clientType);
        }
Example #2
0
        internal static DbClientType CommonToDb(this ClientType clientType)
        {
            DbClientType dbClientType = new DbClientType()
            {
                Id          = clientType.Id,
                MinutePrice = clientType.MinutePrice,
                SMSPrice    = clientType.SMSPrice,
                TypeName    = clientType.TypeName
            };

            return(dbClientType);
        }
Example #3
0
        public static bool Initialization(DbClientType type, string providerName, string connectionString)
        {
            var dbID = type.ToString();

            try
            {
                DbRegistry.RegisterDatabase(dbID, providerName, connectionString);
            }
            catch (Exception ex)
            {
                AppFramework.WriteLog(ex);
                return(false);
            }
            return(true);
        }
Example #4
0
        public void DbToCommon_GetClientType_Convert()
        {
            //Arrange
            var commonClientType = new ClientType();
            var dbClientType     = new DbClientType();

            var fake = A.Fake <ClientType>(o => o.Wrapping(commonClientType));
            //Act
            var results = dbClientType.DbToCommon();

            A.CallTo(() => fake.Equals(A <object> ._)).ReturnsLazily(
                call =>
            {
                var other = call.GetArgument <ClientType>(0);
                return(results.Id == other.Id);
            });
            //Assert
            Assert.AreEqual(fake, results);
        }
Example #5
0
        public static IDbClient CreateDbClient(DbClientType type, string connectionString, int?defaultReadTimeout = null, int?defaultWriteTimeout = null)
        {
            switch (type)
            {
            case DbClientType.SqlServer:
                return(new SqlDbClient(connectionString)
                {
                    DefaultReadTimeout = defaultReadTimeout, DefaultWriteTimeout = defaultWriteTimeout
                });

            case DbClientType.MySql:
                return(new MysqlDbClient(connectionString)
                {
                    DefaultReadTimeout = defaultReadTimeout, DefaultWriteTimeout = defaultWriteTimeout
                });

            case DbClientType.Oracle:
            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }