public void SelectDataInKeyValueFormatTest() { const string connectionString = @"datasource=localhost;Database=crate;port=3306;username=root;password=root;"; var dc = new MySqlContext(connectionString, ""); var p = new Person { Name = "John Doe", Age = 24, Email = "*****@*****.**" }; var repository = new Repository("ConsoleApp"); dc.Clear<Person>(repository); repository.Add(p); dc.SubmitChanges(repository); var people = dc.Select(repository.Name, "Person").ToList(); Assert.AreEqual(4, people[0].Count()); }
public void ClearItemsOfCertainTypeFromRepositoryTest() { const string connectionString = @"datasource=localhost;Database=crate;port=3306;username=root;password=root;"; var dc = new MySqlContext(connectionString, ""); var p = new Person { Name = "John Doe", Age = 24, Email = "*****@*****.**" }; var repository = new Repository("ConsoleApp"); repository.Add(p); dc.SubmitChanges(repository); dc.Clear<Person>(repository); var people = dc.Select<Person>(repository); Assert.AreEqual(0, people.Count()); }
public void UpdateEntryTest() { const string connectionString = @"datasource=localhost;Database=crate;port=3306;username=root;password=root;"; var dc = new MySqlContext(connectionString, ""); var p = new Person { Name = "John Doe", Age = 24, Email = "*****@*****.**" }; var repository = new Repository("ConsoleApp"); dc.Clear<Person>(repository); repository.Add(p); dc.SubmitChanges(repository); var man = dc.Select<Person>(repository).First(c => c.Age == 24); man.Age = 35; repository.Update(man); dc.SubmitChanges(repository); var actual = dc.Select<Person>(repository).First(c => c.Age == 35); Assert.AreEqual(35, actual.Age); }