public void Delete_Wrong_Context() { TestObjClass obj = GetContext().Find <TestObjClass>(1); ctx.Delete(obj); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Deleted)); }
public void GetList_GetListOf() { List <TestObjClass> list = ctx.GetQuery <TestObjClass>().ToList(); Assert.That(list, Is.Not.Null); Assert.That(list.Count, Is.AtLeast(2)); TestObjClass obj = ctx.Find <TestObjClass>(1); List <TestObjClass> listOf = ctx.GetListOf <TestObjClass>(obj, "Children"); Assert.That(listOf, Is.Not.Null); Assert.That(listOf.Count, Is.AtLeast(2)); TestObjClass obj_list = list.Single(o => o.ID == 3); Assert.That(obj_list, Is.Not.Null); Assert.That(obj_list.ID, Is.EqualTo(3)); TestObjClass obj_listOf = listOf.Single(o => o.ID == 3); Assert.That(obj_listOf, Is.Not.Null); Assert.That(obj_listOf.ID, Is.EqualTo(3)); Assert.That(object.ReferenceEquals(obj_list, obj_listOf), "obj_list & obj_listOf are different Objects"); }
public override void SetUp() { base.SetUp(); ctx = GetContext(); obj = ctx.Create<TestObjClass>(); obj.StringProp = "Some String"; }
public void Delete() { TestObjClass obj = ctx.GetQuery <TestObjClass>().First(); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); ctx.Delete(obj); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Deleted)); }
public void Create_ObjectType() { using (IZetboxContext ctx = GetContext()) { TestObjClass newObj = ctx.Create(iftFactory(typeof(TestObjClass))) as TestObjClass; Assert.That(newObj, Is.Not.Null); Assert.That(newObj.Context, Is.Not.Null); } }
public void Create_T() { TestObjClass obj = ctx.Create <TestObjClass>(); Assert.That(obj, Is.Not.Null); Assert.That(obj.ID, Is.LessThan(Helper.INVALIDID)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.New)); Assert.That(obj.Context, Is.EqualTo(ctx)); }
public void Create_ObjectType() { TestObjClass obj = ctx.Create(_iftFactory(typeof(TestObjClass))) as TestObjClass; Assert.That(obj, Is.Not.Null); Assert.That(obj.ID, Is.LessThan(Helper.INVALIDID)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.New)); Assert.That(obj.Context, Is.EqualTo(ctx)); }
public void Detach_IDataObject() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = ctx.GetQuery <TestObjClass>().First(); ctx.Detach(obj); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached)); } }
public void Find_ObjectType_returns_right_object() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = (TestObjClass)ctx.Find(iftFactory(typeof(TestObjClass)), firstId); Assert.That(obj, Is.Not.Null); Assert.That(obj.ID, Is.EqualTo(firstId)); Assert.That(obj.TestEnumProp, Is.EqualTo(TestEnum.First)); } }
public void Find_T_returns_right_object() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = ctx.Find <TestObjClass>(firstId); Assert.That(obj, Is.Not.Null); Assert.That(obj.ID, Is.EqualTo(firstId)); Assert.That(obj.TestEnumProp, Is.EqualTo(TestEnum.First)); } }
public void GetListOf() { TestObjClass o = (TestObjClass)ctx.Find(_iftFactory(typeof(TestObjClass)), 1); List <TestObjClass> list = ctx.GetListOf <TestObjClass>(o, "Children"); Assert.That(list, Is.Not.Null); Assert.That(list.Count, Is.AtLeast(2)); list.ForEach(obj => Assert.That(obj, Is.Not.Null)); list.ForEach(obj => Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified))); list.ForEach(obj => Assert.That(obj.Context, Is.EqualTo(ctx))); }
public void Find_ObjectType_should_return_correct_item() { int targetId = 1; TestObjClass obj = (TestObjClass)ctx.Find(_iftFactory(typeof(TestObjClass)), targetId); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.InstanceOf(typeof(TestObjClass))); Assert.That(obj.ID, Is.EqualTo(targetId)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); Assert.That(obj.Context, Is.EqualTo(ctx)); }
public void should_not_change_on_First() { TestObjClass obj = ctx.GetQuery <TestObjClass>().First(i => i.ID == 1); Assert.That(obj.StringProp, Is.EqualTo("String 1")); obj.StringProp = "Changed"; TestObjClass obj_test = ctx.GetQuery <TestObjClass>().First(i => i.ID == 1); Assert.That(obj_test.StringProp, Is.EqualTo("Changed")); Assert.That(obj.StringProp, Is.EqualTo("Changed")); Assert.That(obj, Is.SameAs(obj_test)); }
public void should_not_change_on_Find() { TestObjClass obj = ctx.Find <TestObjClass>(1); Assert.That(obj.StringProp, Is.EqualTo("String 1")); obj.StringProp = "Changed"; TestObjClass obj_test = ctx.Find <TestObjClass>(1); Assert.That(obj_test.StringProp, Is.EqualTo("Changed")); Assert.That(obj.StringProp, Is.EqualTo("Changed")); Assert.That(obj, Is.SameAs(obj_test)); }
public void SubmitChanges_Nothing() { TestObjClass obj = ctx.Find <TestObjClass>(1); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); int result = ctx.SubmitChanges(); Assert.That(result, Is.EqualTo(0)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); Assert.That(obj.Context, Is.EqualTo(ctx)); }
public void SubmitChanges_New() { TestObjClass obj = ctx.Create <TestObjClass>(); obj.StringProp = "Test"; Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.New)); int result = ctx.SubmitChanges(); Assert.That(result, Is.EqualTo(1)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); Assert.That(obj.Context, Is.EqualTo(ctx)); }
public void should_change_on_GetList() { TestObjClass obj = ctx.GetQuery <TestObjClass>().First(i => i.ID == 1); Assert.That(obj.StringProp, Is.EqualTo("String 1")); obj.StringProp = "Changed"; var lst = ctx.GetQuery <TestObjClass>().ToList(); TestObjClass obj_test = ctx.Find <TestObjClass>(1); Assert.That(lst.Count, Is.GreaterThan(0)); Assert.That(obj.StringProp, Is.EqualTo("String 1")); Assert.That(obj_test.StringProp, Is.EqualTo("String 1")); Assert.That(obj, Is.SameAs(obj_test)); }
public void SubmitChanges_Delete() { TestObjClass obj = ctx.Find <TestObjClass>(1); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); ctx.Delete(obj); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Deleted)); int result = ctx.SubmitChanges(); Assert.That(result, Is.EqualTo(1)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Deleted)); Assert.That(obj.Context, Is.Null); }
public void Create_T_Twice() { TestObjClass obj1 = ctx.Create <TestObjClass>(); Assert.That(obj1, Is.Not.Null); Assert.That(obj1.ID, Is.LessThan(Helper.INVALIDID)); Assert.That(obj1.Context, Is.EqualTo(ctx)); TestObjClass obj2 = ctx.Create <TestObjClass>(); Assert.That(obj2, Is.Not.Null); Assert.That(obj2.ID, Is.LessThan(Helper.INVALIDID)); Assert.That(obj2.Context, Is.EqualTo(ctx)); Assert.That(obj1, Is.Not.EqualTo(obj2)); }
public void Create_Generic() { using (IZetboxContext ctx = GetContext()) { bool hasCreated = false; GenericEventHandler <IPersistenceObject> createdHandler = new GenericEventHandler <IPersistenceObject>(delegate(object obj, GenericEventArgs <IPersistenceObject> e) { hasCreated = true; }); ctx.ObjectCreated += createdHandler; TestObjClass newObj = ctx.Create <TestObjClass>(); Assert.That(newObj, Is.Not.Null); Assert.That(newObj.Context, Is.Not.Null); Assert.That(hasCreated, Is.True); ctx.ObjectCreated -= createdHandler; } }
public void SubmitChanges() { int testId = 1; string testString = "Test"; TestObjClass obj = ctx.Find <TestObjClass>(testId); obj.StringProp = testString; Assert.That(obj.ID, Is.EqualTo(testId)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Modified)); int result = ctx.SubmitChanges(); Assert.That(result, Is.EqualTo(1)); Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.Unmodified)); Assert.That(obj.Context, Is.EqualTo(ctx)); Assert.That(obj.StringProp, Is.EqualTo(testString)); }
public void FromStream_Attached() { var typeMap = scope.Resolve <TypeMap>(); var ms = new MemoryStream(); var sw = new ZetboxStreamWriter(typeMap, new BinaryWriter(ms)); var sr = new ZetboxStreamReader(typeMap, new BinaryReader(ms)); obj.ToStream(sw, null, false); Assert.That(ms.Length, Is.GreaterThan(0)); ms.Seek(0, SeekOrigin.Begin); var ctxMock = GetContext(); TestObjClass result = ctxMock.Create <TestObjClass>(); Assert.That(result.IsAttached, Is.True); Assert.That(() => result.FromStream(sr), Throws.InstanceOf <InvalidOperationException>()); }
public void UpdateSomeData_SubmitChanges() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = ctx.Find <TestObjClass>(firstId); Assert.That(obj, Is.Not.Null); Assert.That(obj.StringProp, Is.EqualTo("First")); obj.StringProp = "Test"; ctx.SubmitChanges(); } using (IZetboxContext ctx = GetContext()) { TestObjClass obj = ctx.Find <TestObjClass>(firstId); Assert.That(obj, Is.Not.Null); Assert.That(obj.StringProp, Is.EqualTo("Test")); } }
public void GetObject_GetList() { TestObjClass obj = ctx.Find <TestObjClass>(1); Assert.That(obj, Is.Not.Null); Assert.That(obj.ID, Is.EqualTo(1)); List <TestObjClass> list = ctx.GetQuery <TestObjClass>().ToList(); Assert.That(list, Is.Not.Null); Assert.That(list.Count, Is.AtLeast(2)); TestObjClass obj_list = list.Single(o => o.ID == 1); Assert.That(obj_list, Is.Not.Null); Assert.That(obj_list.ID, Is.EqualTo(1)); Assert.That(object.ReferenceEquals(obj, obj_list), "obj & obj_list are different Objects"); }
public static void ServerObjParameter(MethodTest obj, MethodReturnEventArgs<TestObjClass> e, TestObjClass input) { var ctx = obj.Context; var newA = ctx.Create<TestObjClass>(); newA.StringProp = "A"; var kundeA = ctx.Create<Kunde>(); kundeA.Kundenname = "Kunde A"; kundeA.PLZ = "1210"; newA.ObjectProp = kundeA; var newB = ctx.Create<TestObjClass>(); newB.StringProp = "B"; var kundeB = ctx.Create<Kunde>(); kundeB.Kundenname = "Kunde"; kundeB.PLZ = "1210"; newB.ObjectProp = kundeB; e.Result = input ?? newA; }
public void GetListOf_Twice() { TestObjClass o = (TestObjClass)ctx.Find(_iftFactory(typeof(TestObjClass)), 1); List <TestObjClass> list1 = ctx.GetListOf <TestObjClass>(o, "Children"); Assert.That(list1, Is.Not.Null); Assert.That(list1.Count, Is.AtLeast(2)); list1.ForEach(obj => Assert.That(o, Is.Not.Null)); List <TestObjClass> list2 = ctx.GetListOf <TestObjClass>(o, "Children"); Assert.That(list2, Is.Not.Null); Assert.That(list2.Count, Is.EqualTo(list1.Count)); list2.ForEach(obj => Assert.That(o, Is.Not.Null)); for (int i = 0; i < list1.Count; i++) { Assert.That(list1[i], Is.EqualTo(list2[i])); } }
public TestObjClassViewModel( IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, TestObjClass obj) : base(appCtx, dataCtx, parent, obj) { }
public static void get_CalculatedEnumeration(TestObjClass obj, PropertyGetterEventArgs<TestEnum> e) { e.Result = obj.ID % 2 == 0 ? TestEnum.First : TestEnum.Second; }