public void ValidateCustomAttribute() { _person = SamplePerson.GetSamplePerson(); Debug.Assert(_person.Validate(), "Custom Validation failed"); _person.Custom = "0"; Debug.Assert(!_person.Validate(), "Custom Validation failed"); }
public void ValidateIdentityAttribute() { _person = SamplePerson.GetSamplePerson(); _person.Identity = 0; Debug.Assert(_person.Validate(), "Identity Validation unexpected fail"); _person.Identity = 1; Debug.Assert(_person.Validate(), "Identity Validation unexpected fail"); }
public void ValidateIntegerAttribute() { _person = SamplePerson.GetSamplePerson(); _person.FkMother = 0; Debug.Assert(!_person.Validate(), "Integer Validation failed"); _person.FkMother = 1; Debug.Assert(_person.Validate(), "Integer Validation unexpected fail"); _person.FkCompany = 0; Debug.Assert(_person.Validate(), "Integer Validation unexpected fail"); }
public void ValidateStringAttribute() { _person = SamplePerson.GetSamplePerson(); _person.Lastname = "Testname"; Debug.Assert(_person.Validate(), "Required string check failed"); _person.Firstname = "Something"; Debug.Assert(_person.Validate(), "Optional string check failed"); _person.Lastname = ""; Debug.Assert(!_person.Validate(), "Required string check failed"); _person.Firstname = ""; Debug.Assert(!_person.Validate(), "Optional string check failed"); _person.Firstname = "12345678910"; Debug.Assert(!_person.Validate(), "String overflow failure"); }
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 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 BasicSave() { _person = SamplePerson.GetSamplePerson(); var id = _person.Save(); Assert.AreNotEqual(id, 0); _person.Load(); Assert.AreEqual(id, _person.Identity); }
public void BasicLoadList() { _person = SamplePerson.GetSamplePerson(); _person.Save(); var list = _person.LoadList(); Assert.AreNotEqual(list.Count, 0); }
public void TestJsonUnorderedRead() { var jd = new JsonDeserializer(); jd.Options.TagMode = TagMode.Aliases; jd.JsonOptions.Unordered = true; SamplePerson p = new SamplePerson(); jsonStream.Position = 0; jd.FromStream(p, jsonStream); Assert.AreEqual(person.Name, p.Name); }
public void TestBinaryRead() { var bd = new BinaryDeserializer(); SamplePerson p = new SamplePerson(); binaryStream.Position = 0; bd.FromStream(p, binaryStream); Assert.AreEqual(person.Name, p.Name); }
public static void Init(TestContext context) { SamplePerson.Counter = 0; Random rnd = new Random(20151125); person = new SamplePerson(rnd, 1); var js = new JsonSerializer(); js.JsonOptions.Indent = ""; js.JsonOptions.FieldSeparator = ""; js.Options.TagMode = TagMode.Aliases; js.ToStream(person, jsonStream); var bs = new BinarySerializer(); bs.ToStream(person, binaryStream); ProtoBuf.Serializer.Serialize(protobufStream, person); }