public void BasicCrudTests() { _person = new SamplePerson(); var li = _person.LoadList(); foreach (var samplePerson in li) { samplePerson.Delete(); } _person = SamplePerson.GetSamplePerson(); Debug.Assert(_person.Save() != 0, "Failed to insert person"); var id = _person.Identity; _person = new SamplePerson { Identity = id }; Debug.Assert(_person.Load() && _person.FkMother == 1 && _person.Firstname != "" && _person.Lastname != "", "Load single object failed"); var list = _person.LoadList(); Debug.Assert(list.Count > 0 && list[0].FkCompany == 1 && list[0].FkMother == 1 && list[0].Firstname != "" && list[0].Lastname != "", "Load List failed"); _person.Lastname = "UpdatedLastName"; _person.Firstname = null; _person.FkCompany = 0; _person.FkMother = 100; _person.Boolean = false; _person.NullableDateTime = DateTime.Now; _person.Save(); _person.Load(); Debug.Assert(_person.Lastname == "UpdatedLastName" && _person.FkCompany == 0 && _person.FkMother == 100 && _person.Firstname != "", "Failed to update person"); list = _person.LoadList("FkCompany", 0); Debug.Assert(list.Count > 0, "Failed to load List by Key"); var qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", _person.Identity, DatabaseOperator.Equal)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", 0, DatabaseOperator.GreaterThan)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed greater than query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", _person.Identity, DatabaseOperator.GreaterThanOrEqual)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed greater than or equal query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", Int32.MaxValue, DatabaseOperator.LessThan)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed less than query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", _person.Identity, DatabaseOperator.LesserThanOrEqual)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed greater than query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("SamplePersonId", 0, DatabaseOperator.NotEqualTo)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed not equal query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("Lastname", _person.Lastname, DatabaseOperator.Equal)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed greater than query builder"); qb = QueryBuilder.GetQueryBuilder(_person, new Query("Lastname", _person.Lastname.Substring(2), DatabaseStringOperator.Like)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed string query builder"); var dt = new DateTime(2000, 10, 21); qb = QueryBuilder.GetQueryBuilder(_person, new Query("Date", dt, DatabaseOperator.GreaterThan)); list = _person.LoadList(qb.GetQuery()); Debug.Assert(list.Count > 0, "Failed datetime query builder"); var pers = new SamplePerson { Lastname = "last", FkMother = 100, Boolean = false, }; list = pers.LoadByClass(); Debug.Assert(list.Count > 0, "Failed to load List by Class"); Debug.Assert(_person.Delete(), "Failed to delete person"); }
public void UpdateNullValues() { _person = SamplePerson.GetSamplePerson(); _person.Save(); _person.Firstname = null; var id = _person.Save(); _person = new SamplePerson { Identity = id, }; _person.Load(); Debug.Assert(_person.Firstname == null, "Update null string failed"); _person.FkCompany = null; _person.Save(); _person = new SamplePerson { Identity = id, }; _person.Load(); Debug.Assert(_person.FkCompany == null, "Update null int failed"); _person.NullableDateTime = null; _person.Save(); _person = new SamplePerson { Identity = id, }; _person.Load(); Debug.Assert(_person.NullableDateTime == null, "Update null datetime failed"); }
public void BasicSave() { _person = SamplePerson.GetSamplePerson(); var id = _person.Save(); Assert.AreNotEqual(id, 0); _person.Load(); Assert.AreEqual(id, _person.Identity); }
public void InsertNullValues() { _person = SamplePerson.GetSamplePerson(); _person.FkCompany = null; Debug.Assert(_person.Save() != 0, "Insert null int failed"); _person = SamplePerson.GetSamplePerson(); _person.Firstname = null; Debug.Assert(_person.Save() != 0, "Insert null string failed"); _person = SamplePerson.GetSamplePerson(); _person.NullableDateTime = null; Debug.Assert(_person.Save() != 0, "Insert null date failed"); }
public void BasicLoadList() { _person = SamplePerson.GetSamplePerson(); _person.Save(); var list = _person.LoadList(); Assert.AreNotEqual(list.Count, 0); }