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); }
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); }
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); }
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); }
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); } }