public void Test_MultiThreadBuildQuery() { var instance = new BugReadOnlyBreakUpsertStatement(); var obj2Sql = new Services.ObjectToSql(DataBaseType.SqlServer); for (var i2 = 0; i2 < 200; i2++) { Thread[] threads = new Thread[6]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(delegate(object sdo) { var quwery = obj2Sql.BuildQuery(ActionType.Insert, instance); var parameters = obj2Sql.BuildDbParameterList(instance, (s, o) => new SqlParameter(s, o)); }); } foreach (Thread thread in threads) { thread.Start(); } foreach (Thread thread in threads) { thread.Join(); } } }
public void Test_BuildDbParameterList_Contains_Accurate_Values() { var employee = new Employee() { LastName = "John", FirstName = "Doe" }; var objectToSql = new Services.ObjectToSql(DataBaseType.SqlServer); var parameters = objectToSql.BuildDbParameterList(employee, (s, o) => new SqlParameter(s, o), null, null, null); Assert.AreEqual(parameters.First().Value, "Doe"); Assert.AreEqual(parameters.Last().Value, "John"); Assert.AreEqual(parameters.Count, 2); }
public void Test_Object2Sql_ConvertSQLToReadable() { var obj2Sql = new Services.ObjectToSql(DataBaseType.SqlServer); // create an object you want to convert to sql var employee = new Employee(); // create dbparameters from my object var dbParameters = obj2Sql.BuildDbParameterList(employee, (s, o) => new SqlParameter(s, o)); // create my parameterized sql based on my specified action type var insertSql = obj2Sql.BuildQuery <Employee>(ActionType.Insert); // convert my parameterize sql to be readable var readAble = obj2Sql.SqlSyntaxHelper.ConvertParameterSqlToReadable(dbParameters, insertSql, Encoding.UTF8); // unit test Assert.AreEqual(readAble, "INSERT INTO Employee ([FirstName],[LastName]) VALUES (NULL,NULL)"); }