public void TestPersonWithIdIsOne() { IPerson mockPerson = table.GetTable().First(p => p.Id == 1); using (MySqlConnection conn = new MySqlConnection(MySqlUtility.ConnectionString)) { conn.Open(); var person = conn.Get<Person>("select Id,Name from person where Id = @Id", new { Id = 1 }); Assert.IsNotNull(person); Assert.AreEqual(mockPerson.Id, person.Id); Assert.AreEqual(mockPerson.Name, person.Name); } }
public void GetAllWithId5() { IPerson mockPerson = table.GetTable().First(p => p.Id == 5); using (MySqlConnection conn = new MySqlConnection(MySqlUtility.ConnectionString)) { conn.Open(); var person = conn.Get<Person>("select * from person where Id = @Id", new { Id = 5 }); Assert.IsNotNull(person); Assert.AreEqual(mockPerson.Id, person.Id); Assert.AreEqual(mockPerson.Name, person.Name); Assert.AreEqual(mockPerson.DateOfBirth, person.DateOfBirth); Assert.AreEqual(mockPerson.SSN, person.SSN); Assert.AreEqual(mockPerson.BankAccount, person.BankAccount); Assert.AreEqual(mockPerson.NoofCars, person.NoofCars); Assert.AreEqual(mockPerson.IsPremium, person.IsPremium); } }
public void NullName() { using (MySqlConnection conn = new MySqlConnection(MySqlUtility.ConnectionString)) { conn.Open(); var person = conn.Get<Person>("Select NULL As Name"); Assert.IsNotNull(person); Assert.AreEqual(null, person.Name); } }