public void TestIntegrationScalarQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper"); var id = queryRunner.ExecuteScalar <int>(new QueryUsers()); Assert.AreEqual(1, id); }
public void TestIntegrationScalarQuery() { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings); var id = queryRunner.ExecuteScalar <int>(new QueryUsers()); Assert.AreEqual(1, id); }
public void TestIntegrationSingleResultMapperQuery() { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings); var user = queryRunner.Execute <SimpleDto>(new QueryUsers(1)).ToSingle(); Assert.IsNotNull(user); }
public void TestIntegrationFirstOrDefaultWithoutResultMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); var user = queryRunner.Execute <SimpleDto>(new QueryUsers(99)).ToFirstOrDefault(); Assert.IsNull(user); }
public void TestIntegrationSingleResultMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); var user = queryRunner.Execute <SimpleDto>(new QueryUsers(1)).ToSingle(); Assert.IsNotNull(user); }
public void TestIntegrationSingleResultFailManyResultMapperQuery() { Assert.ThrowsException <InvalidOperationException>(() => { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings); queryRunner.Execute <SimpleDto>(new QueryUsers()).ToSingle(); }); }
public void TestIntegrationFirstOrDefaultWithResultMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); var user = queryRunner.Execute <SimpleDto>(new QueryUsers()).ToFirstOrDefault(); Assert.IsNotNull(user); Assert.AreEqual(1, user.Id); Assert.AreEqual("User 1", user.Name); }
public void TestDependencyInjectionCreateHelper() { var container = new UnityContainer(); container.RegisterType <IQueryRunner>(new InjectionFactory(c => QueryRunner.CreateHelper("MockAdoHelper"))); var mockAdo = container.Resolve <IQueryRunner>(); Assert.IsInstanceOfType(mockAdo, typeof(MockQueryRunner)); }
public void TestIntegrationWhithoutGlobalCacheResultOneToManyMapperQuery() { using (var queryMapper = new QueryMapper()) { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings, queryMapper); var user = queryRunner.Execute <NameValue>(new QueryOneToManyMapObject(1)).ToFirstOrDefault(); Assert.AreEqual("123456", user.Phones.FirstOrDefault(p => p.Id == 1).Name); Assert.AreEqual("*****@*****.**", user.Emails.FirstOrDefault(e => e.Id == 1).Name); } }
public void TestIntegrationDataTableQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper"); var dt = queryRunner.ExecuteDataTable(new QueryUsers()); Assert.IsNotNull(dt); Assert.IsNotNull(dt.Rows); Assert.AreEqual(2, dt.Rows.Count); Assert.AreEqual(1, Convert.ToInt32(dt.Rows[0]["Id"])); Assert.AreEqual("User 1", Convert.ToString(dt.Rows[0]["Name"])); }
public void TestIntegrationDataReaderQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper"); using (var dr = queryRunner.ExecuteReader(new QueryUsers())) { Assert.IsNotNull(dr); Assert.IsTrue(dr.Read()); Assert.AreEqual(1, Convert.ToInt32(dr["Id"])); Assert.AreEqual("User 1", Convert.ToString(dr["Name"])); } }
public void TestIntegrationDataReaderQuery() { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings); using (var dr = queryRunner.ExecuteReader(new QueryUsers())) { Assert.IsNotNull(dr); Assert.IsTrue(dr.Read()); Assert.AreEqual(1, Convert.ToInt32(dr["Id"])); Assert.AreEqual("Diana Hendrix", Convert.ToString(dr["Name"])); } }
public void TestIntegrationFirstOrDefaultWithResultMapperQuery() { using (var queryMapper = new QueryMapper()) { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings, queryMapper); var user = queryRunner.Execute(new QueryUsers()).ToFirstOrDefault(); Assert.IsNotNull(user); Assert.AreEqual(1, user.Id); Assert.AreEqual("Diana Hendrix", user.Name); } }
public void TestIntegrationWhithoutExecuteCacheResultMapperQuery() { QueryMapper.RemoveCacheAfterExecuteQuery = false; using (var queryMapper = new QueryMapper()) { var queryRunner = QueryRunner.CreateHelper(dataAccessSettings, queryMapper); var user = queryRunner.Execute(new QueryUsers(1), keepCache: false).ToSingle(); var phone = queryRunner.Execute(new QueryPhone(1), keepCache: false).ToSingle(); Assert.AreEqual(1, phone.Id); Assert.AreNotEqual(user.Name, phone.Name); } }
public void TestIntegrationOneToManyMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); var users = queryRunner.Execute <SimpleDto>(new QueryOneToMany()).ToList(); Assert.IsNotNull(users); // ReSharper disable PossibleMultipleEnumeration Assert.AreEqual(2, users.Count()); var user = users.First(); // ReSharper restore PossibleMultipleEnumeration Assert.IsNotNull(user.Phones); Assert.AreEqual(2, user.Phones.Count()); }
public void TestIntegrationPerformanceOneToManyMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); var iterations = 50000; var stopwatch = Stopwatch.StartNew(); for (var i = 0; i < iterations; i++) { var users = queryRunner.Execute <SimpleDto>(new QueryOneToMany()).ToList(); Assert.IsNotNull(users); // ReSharper disable PossibleMultipleEnumeration Assert.AreEqual(2, users.Count()); var user = users.First(); // ReSharper restore PossibleMultipleEnumeration Assert.IsNotNull(user.Phones); Assert.AreEqual(2, user.Phones.Count()); } Trace.WriteLine(string.Format("Mapped {0} objects in {1} ms.", iterations, stopwatch.ElapsedMilliseconds)); }
public void TestIntegrationSingleResultFailManyResultMapperQuery() { var queryRunner = QueryRunner.CreateHelper("SqlAdoHelper", new QueryMapper()); queryRunner.Execute <SimpleDto>(new QueryUsers()).ToSingle(); }
public void TestCreateHelper() { var mockAdo = QueryRunner.CreateHelper("MockAdoHelper"); Assert.IsInstanceOfType(mockAdo, typeof(MockQueryRunner)); }