protected void SubmitAndReload() { ctx.SubmitChanges(); ctx = GetContext(); aSide1 = ctx.Find <N_to_M_relations_A>(aSide1.ID); aSide2 = ctx.Find <N_to_M_relations_A>(aSide2.ID); bSide1 = ctx.Find <N_to_M_relations_B>(bSide1.ID); bSide2 = ctx.Find <N_to_M_relations_B>(bSide2.ID); }
protected virtual void SubmitAndReload() { ctx.SubmitChanges(); ctx = GetContext(); aSide1 = ctx.Find<N_to_M_relations_A>(aSide1.ID); aSide2 = ctx.Find<N_to_M_relations_A>(aSide2.ID); bSide1 = ctx.Find<N_to_M_relations_B>(bSide1.ID); bSide2 = ctx.Find<N_to_M_relations_B>(bSide2.ID); }
protected virtual void Reload() { ctx = GetContext(); identity1 = ctx.Find<Identity>(identity1.ID); identity2 = ctx.Find<Identity>(identity2.ID); parent = ctx.Find<SecurityTestParent>(parent.ID); child1 = ctx.Find<SecurityTestChild>(child1.ID); child2 = ctx.Find<SecurityTestChild>(child2.ID); }
protected virtual void Reload() { ctx = GetContext(); identity1 = ctx.Find <Identity>(identity1.ID); identity2 = ctx.Find <Identity>(identity2.ID); parent = ctx.Find <SecurityTestParent>(parent.ID); child1 = ctx.Find <SecurityTestChild>(child1.ID); child2 = ctx.Find <SecurityTestChild>(child2.ID); }
protected void SubmitAndReload() { ctx.SubmitChanges(); hasSubmitted = true; ctx = GetContext(); oneSide1 = ctx.Find<One_to_N_relations_One>(oneSide1.ID); oneSide2 = ctx.Find<One_to_N_relations_One>(oneSide2.ID); oneSide3 = ctx.Find<One_to_N_relations_One>(oneSide3.ID); nSide1 = ctx.Find<One_to_N_relations_N>(nSide1.ID); nSide2 = ctx.Find<One_to_N_relations_N>(nSide2.ID); }
protected void SubmitAndReload() { ctx.SubmitChanges(); hasSubmitted = true; ctx = GetContext(); oneSide1 = ctx.Find<RequiredParent>(oneSide1.ID); oneSide2 = ctx.Find<RequiredParent>(oneSide2.ID); oneSide3 = ctx.Find<RequiredParent>(oneSide3.ID); nSide1 = ctx.Find<RequiredParentChild>(nSide1.ID); nSide2 = ctx.Find<RequiredParentChild>(nSide2.ID); }
protected void SubmitAndReload() { ctx.SubmitChanges(); hasSubmitted = true; ctx = GetContext(); oneSide1 = ctx.Find <RequiredParent>(oneSide1.ID); oneSide2 = ctx.Find <RequiredParent>(oneSide2.ID); oneSide3 = ctx.Find <RequiredParent>(oneSide3.ID); nSide1 = ctx.Find <RequiredParentChild>(nSide1.ID); nSide2 = ctx.Find <RequiredParentChild>(nSide2.ID); }
protected void SubmitAndReload() { ctx.SubmitChanges(); hasSubmitted = true; ctx = GetContext(); oneSide1 = ctx.Find <One_to_N_relations_One>(oneSide1.ID); oneSide2 = ctx.Find <One_to_N_relations_One>(oneSide2.ID); oneSide3 = ctx.Find <One_to_N_relations_One>(oneSide3.ID); nSide1 = ctx.Find <One_to_N_relations_N>(nSide1.ID); nSide2 = ctx.Find <One_to_N_relations_N>(nSide2.ID); }
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 override void SetUp() { base.SetUp(); ctx = GetContext(); var principalResolver = scope.Resolve<IPrincipalResolver>(); var currentPrincipal = principalResolver.GetCurrent(); Assert.That(currentPrincipal, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly"); identity1 = ctx.Find<Identity>(currentPrincipal.ID); identity2 = ctx.GetQuery<Identity>().Where(i => i.ID != identity1.ID).First(); parent = ctx.Create<SecurityTestParent>(); parent.Name = "MyParent"; child1 = ctx.Create<SecurityTestChild>(); child1.Name = "Child1"; child1.Identity = identity1; child1.Parent = parent; child2 = ctx.Create<SecurityTestChild>(); child2.Name = "Child2"; child2.Identity = identity2; child2.Parent = parent; ctx.SubmitChanges(); }
public override void SetUp() { base.SetUp(); ctx = GetContext(); var idResolver = scope.Resolve <IIdentityResolver>(); var currentIdentity = idResolver.GetCurrent(); Assert.That(currentIdentity, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly"); identity1 = ctx.Find <Identity>(currentIdentity.ID); identity2 = ctx.GetQuery <Identity>().Where(i => i.ID != identity1.ID).First(); parent = ctx.Create <SecurityTestParent>(); parent.Name = "MyParent"; child1 = ctx.Create <SecurityTestChild>(); child1.Name = "Child1"; child1.Identity = identity1; child1.Parent = parent; child2 = ctx.Create <SecurityTestChild>(); child2.Name = "Child2"; child2.Identity = identity2; child2.Parent = parent; ctx.SubmitChanges(); }
public void Sort_Relation_n_m_m() { int maID = 0; using (IZetboxContext ctx = GetContext()) { var ma = ctx.GetQuery <Zetbox.App.Projekte.Mitarbeiter>().ToList() .OrderByDescending(p => p.Projekte.Count).First(); maID = ma.ID; var tmpProjekte = ma.Projekte.ToList(); ma.Projekte.Clear(); foreach (Zetbox.App.Projekte.Projekt prj in tmpProjekte .OrderBy(p => p.Name)) { ma.Projekte.Add(prj); } ctx.SubmitChanges(); } using (IZetboxContext ctx = GetContext()) { var ma = ctx.Find <Zetbox.App.Projekte.Mitarbeiter>(maID); var tmpProjekte = ma.Projekte.ToList(); int i = 0; foreach (Zetbox.App.Projekte.Projekt prj in tmpProjekte .OrderBy(p => p.Name)) { Assert.That(prj, Is.EqualTo(tmpProjekte[i++])); } } }
public void Sort_Relation_n_m_n() { int prjID = 0; using (IZetboxContext ctx = GetContext()) { var prj = ctx.GetQuery <Zetbox.App.Projekte.Projekt>().ToList() .OrderByDescending(p => p.Mitarbeiter.Count).First(); prjID = prj.ID; var tmpMitarbeiter = prj.Mitarbeiter.ToList(); prj.Mitarbeiter.Clear(); foreach (Zetbox.App.Projekte.Mitarbeiter m in tmpMitarbeiter .OrderBy(m => m.Name)) { prj.Mitarbeiter.Add(m); } ctx.SubmitChanges(); } using (IZetboxContext ctx = GetContext()) { var prj = ctx.Find <Zetbox.App.Projekte.Projekt>(prjID); var tmpMitarbeiter = prj.Mitarbeiter.ToList(); int i = 0; foreach (Zetbox.App.Projekte.Mitarbeiter m in tmpMitarbeiter .OrderBy(m => m.Name)) { Assert.That(m, Is.EqualTo(tmpMitarbeiter[i++])); } } }
public void Find_T_fails_on_invalid_ID() { using (IZetboxContext ctx = GetContext()) { ctx.Find <TestObjClass>(Zetbox.API.Helper.INVALIDID); } }
private static void MakeInternal(IZetboxContext ctx, ImportedFile obj, File doc) { // Clone blob, so it could be deleted doc.Blob = ctx.Find<Blob>(ctx.CreateBlob(ctx.GetFileInfo(obj.Blob.ID), obj.Blob.MimeType)); doc.Name = obj.Name; ctx.Delete(obj); }
private static void MakeInternal(IZetboxContext ctx, ImportedFile obj, File doc) { // Clone blob, so it could be deleted doc.Blob = ctx.Find <Blob>(ctx.CreateBlob(ctx.GetFileInfo(obj.Blob.ID), obj.Blob.MimeType)); doc.Name = obj.Name; ctx.Delete(obj); }
public void when_ordering_items() { int methodID = Helper.INVALIDID; using (IZetboxContext ctx = GetContext()) { var method = ctx.GetQuery <Method>().ToList().Where(m => m.Module.Name == "Projekte") .OrderByDescending(m => m.Parameter.Count).First(); Assert.That(method.Parameter.Count, Is.GreaterThan(1), "Test data failure: needs more than one Parameter to test ordering"); Assert.That(method.ObjectState, Is.EqualTo(DataObjectState.Unmodified), "Test data failure: method should be unmodified at start of test"); methodID = method.ID; var parameters = method.Parameter.ToList(); method.Parameter.Clear(); Assert.That(method.ObjectState, Is.EqualTo(DataObjectState.Modified)); foreach (BaseParameter p in CanonicalOrdering(parameters)) { method.Parameter.Add(p); } Assert.That(ctx.SubmitChanges(), Is.GreaterThan(0)); } using (IZetboxContext ctx = GetContext()) { var method = ctx.Find <Method>(methodID); var parameters = method.Parameter.ToList(); Assert.That(parameters, Is.EquivalentTo(CanonicalOrdering(parameters)), "mismatch in retrieved parameters"); } }
public void Find_ObjectType_fails_on_invalid_ID() { using (IZetboxContext ctx = GetContext()) { ctx.Find(iftFactory(typeof(TestObjClass)), Zetbox.API.Helper.INVALIDID); } }
public void InitTestObjects() { ctx = GetContext(); oneSide1 = ctx.Create <One_to_N_relations_One>(); oneSide2 = ctx.Create <One_to_N_relations_One>(); oneSide3 = ctx.Create <One_to_N_relations_One>(); nSide1 = ctx.Create <One_to_N_relations_N>(); nSide1.OneSide = oneSide3; nSide2 = ctx.Create <One_to_N_relations_N>(); nSide2.OneSide = oneSide3; ctx.SubmitChanges(); ctx = GetContext(); oneSide1 = ctx.Find <One_to_N_relations_One>(oneSide1.ID); oneSide2 = ctx.Find <One_to_N_relations_One>(oneSide2.ID); oneSide3 = ctx.Find <One_to_N_relations_One>(oneSide3.ID); nSide1 = ctx.Find <One_to_N_relations_N>(nSide1.ID); nSide2 = ctx.Find <One_to_N_relations_N>(nSide2.ID); }
public void InitTestObjects() { ctx = GetContext(); oneSide1 = ctx.Create<One_to_N_relations_One>(); oneSide2 = ctx.Create<One_to_N_relations_One>(); oneSide3 = ctx.Create<One_to_N_relations_One>(); nSide1 = ctx.Create<One_to_N_relations_N>(); nSide1.OneSide = oneSide3; nSide2 = ctx.Create<One_to_N_relations_N>(); nSide2.OneSide = oneSide3; ctx.SubmitChanges(); ctx = GetContext(); oneSide1 = ctx.Find<One_to_N_relations_One>(oneSide1.ID); oneSide2 = ctx.Find<One_to_N_relations_One>(oneSide2.ID); oneSide3 = ctx.Find<One_to_N_relations_One>(oneSide3.ID); nSide1 = ctx.Find<One_to_N_relations_N>(nSide1.ID); nSide2 = ctx.Find<One_to_N_relations_N>(nSide2.ID); }
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 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)); } }
protected virtual void CreateTestData() { data = new MemoryStream(); var sw = new StreamWriter(data); sw.Write(txt_data); using (IZetboxContext ctx = GetContext()) { var blob = ctx.Find <Blob>(ctx.CreateBlob(data, filename, mimetype)); ctx.SubmitChanges(); blob_id = blob.ID; } }
private SavedListConfiguration GetSavedConfig(IZetboxContext ctx) { var config = ctx.GetQuery <SavedListConfiguration>() .Where(i => i.Type.ExportGuid == Parent.DataType.ExportGuid) // Parent.DataType might be from FrozenContext .Where(i => i.Owner == this.CurrentIdentity) .FirstOrDefault(); if (config == null) { config = ctx.Create <SavedListConfiguration>(); config.Owner = ctx.Find <Identity>(CurrentIdentity.ID); config.Type = ctx.FindPersistenceObject <ObjectClass>(Parent.DataType.ExportGuid); // Parent.DataType might be from FrozenContext } return(config); }
public void GetList_GetOneObject() { using (IZetboxContext ctx = GetContext()) { var list_objclass = ctx.GetQuery <DataType>().ToList(); Assert.That(list_objclass.Count, Is.GreaterThan(0)); var prop = ctx.Find <Property>(1); Assert.That(prop, Is.Not.Null); var objclass = list_objclass.Single(o => o == prop.ObjectClass); var prop_test = objclass.Properties.Single(p => p.ID == prop.ID); Assert.That(object.ReferenceEquals(prop, prop_test), "prop & prop_test are different Objects"); } }
protected void SubmitAndReload() { ctx.SubmitChanges(); ctx = GetContext(); oneSide1 = ctx.Find <OrderedOneEnd>(oneSide1.ID); oneSide2 = ctx.Find <OrderedOneEnd>(oneSide2.ID); oneSide3 = ctx.Find <OrderedOneEnd>(oneSide3.ID); nSide1 = ctx.Find <OrderedNEnd>(nSide1.ID); nSide2 = ctx.Find <OrderedNEnd>(nSide2.ID); nSide3 = ctx.Find <OrderedNEnd>(nSide3.ID); }
protected void SubmitAndReload() { ctx.SubmitChanges(); ctx = GetContext(); oneSide1 = ctx.Find<OrderedOneEnd>(oneSide1.ID); oneSide2 = ctx.Find<OrderedOneEnd>(oneSide2.ID); oneSide3 = ctx.Find<OrderedOneEnd>(oneSide3.ID); nSide1 = ctx.Find<OrderedNEnd>(nSide1.ID); nSide2 = ctx.Find<OrderedNEnd>(nSide2.ID); nSide3 = ctx.Find<OrderedNEnd>(nSide3.ID); }
public Zetbox.App.Base.Blob SetBlobStream(Guid version, IZetboxContext ctx, Stream blob, string filename, string mimetype) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (blob == null) { throw new ArgumentNullException("blob"); } ZetboxGeneratedVersionAttribute.Check(version); var id = ctx.CreateBlob(blob, filename, mimetype); var obj = ctx.Find <Zetbox.App.Base.Blob>(id); ctx.SubmitChanges(); return(obj); }
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 DataObjectViewModel GetDataObject(IZetboxContext ctx) { if (ctx == null) { throw new ArgumentNullException("ctx"); } IDataObject obj; if (ID <= Helper.INVALIDID) { obj = ctx.Create(ZetboxContextManagerModule.IftFactory(Type.GetSystemType())); ID = obj.ID; } else { obj = (IDataObject)ctx.Find(ZetboxContextManagerModule.IftFactory(Type.GetSystemType()), ID); } return(DataObjectViewModel.Fetch(ZetboxContextManagerModule.ViewModelFactory, ctx, null, obj)); }
public void Import(IZetboxContext ctx, Account account, string fileName) { List <ImportedTransaction> importedTransactions = Read(fileName); var min = importedTransactions.Min(i => i.Date).AddDays(-7); var max = importedTransactions.Max(i => i.Date).AddDays(7); var transactions = ctx.GetQuery <Transaction>() .Where(i => i.Account == account) .Where(i => i.Date >= min && i.Date <= max) .ToLookup(k => k.ImportHash); foreach (var impTx in importedTransactions) { if (!transactions.Contains(impTx.ImportHash)) { var newTx = ctx.Create <Transaction>(); newTx.Account = account; newTx.Date = impTx.Date; newTx.Amount = impTx.Ammount; newTx.Comment = impTx.Text; newTx.ImportHash = impTx.ImportHash; foreach (var receipt in impTx.Receipts) { var file = ctx.Create <at.dasz.DocumentManagement.File>(); file.IsFileReadonly = true; file.Name = string.Format("Receipt {0}.txt", impTx.Date.ToShortDateString()); using (var stream = new MemoryStream()) using (var sw = new StreamWriter(stream)) { sw.Write(receipt); sw.Flush(); stream.Seek(0, SeekOrigin.Begin); file.Blob = ctx.Find <Blob>(ctx.CreateBlob(stream, file.Name, "text/plain")); } newTx.Documents.Add(file); } } } }
public IEnumerable <IRelationEntry> GetCollectionEntries( Guid version, IZetboxContext ctx, Guid relId, RelationEndRole endRole, int parentId) { if (ctx == null) { throw new ArgumentNullException("ctx"); } ZetboxGeneratedVersionAttribute.Check(version); var rel = ctx.FindPersistenceObject <Relation>(relId); //var relEnd = rel.GetEndFromRole(endRole); //var relOtherEnd = rel.GetOtherEnd(relEnd); var parent = ctx.Find(ctx.GetImplementationType(typeof(TParent)).ToInterfaceType(), parentId); var ceType = ctx.ToImplementationType(rel.GetEntryInterfaceType()).Type; var method = this.GetType().GetMethod("GetCollectionEntriesInternal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); return((IEnumerable <IRelationEntry>)method .MakeGenericMethod(ceType) .Invoke(this, new object[] { parent, rel, endRole })); }
private SavedListConfiguration GetSavedConfig(IZetboxContext ctx) { var config = ctx.GetQuery<SavedListConfiguration>() .Where(i => i.Type.ExportGuid == Parent.DataType.ExportGuid) // Parent.DataType might be from FrozenContext .Where(i => i.Owner.ID == this.CurrentPrincipal.ID) .FirstOrDefault(); if (config == null) { config = ctx.Create<SavedListConfiguration>(); config.Owner = ctx.Find<Identity>(CurrentPrincipal.ID); config.Type = ctx.FindPersistenceObject<ObjectClass>(Parent.DataType.ExportGuid); // Parent.DataType might be from FrozenContext } return config; }
protected void ActivateForeignItems(IViewModelFactoryScope newScope, IZetboxContext newCtx, IEnumerable<IDataObject> items) { if (newScope == null) throw new ArgumentNullException("newScope"); if (newCtx == null) throw new ArgumentNullException("newCtx"); if (items == null || items.Count() == 0) return; var newWorkspace = ObjectEditor.WorkspaceViewModel.Create(newScope.Scope, newCtx); newScope.ViewModelFactory.ShowModel(newWorkspace, RequestedWorkspaceKind, true); // ShowForeignObject may take a while newScope.ViewModelFactory.CreateDelayedTask(newWorkspace, () => { var newViewModels = items.Select(i => DataObjectViewModel.Fetch(newScope.ViewModelFactory, newCtx, this, newCtx.Find(DataContext.GetInterfaceType(i), i.ID))); var openingArgs = new ItemsOpeningEventArgs(newCtx, newWorkspace, newViewModels); OnItemsOpening(newWorkspace, openingArgs); // abort handling the event if it is already handled if (openingArgs.Handled == true) return; foreach (var newItem in openingArgs.Items) { newWorkspace.ShowModel(newItem); } OnItemsOpened(newWorkspace, new ItemsOpenedEventArgs(openingArgs.Items)); newWorkspace.SelectedItem = newWorkspace.Items.FirstOrDefault(); }).Trigger(); }
public DataObjectViewModel GetDataObject(IZetboxContext ctx) { if (ctx == null) { throw new ArgumentNullException("ctx"); } IDataObject obj; if (ID <= Helper.INVALIDID) { obj = ctx.Create(ZetboxContextManagerModule.IftFactory(Type.GetSystemType())); ID = obj.ID; } else { obj = (IDataObject)ctx.Find(ZetboxContextManagerModule.IftFactory(Type.GetSystemType()), ID); } return DataObjectViewModel.Fetch(ZetboxContextManagerModule.ViewModelFactory, ctx, null, obj); }
private void ReloadObjects(IZetboxContext reloadCtx) { one1 = reloadCtx.Find<One_to_N_relations_One>(one1.ID); one2 = reloadCtx.Find<One_to_N_relations_One>(one2.ID); n1 = reloadCtx.Find<One_to_N_relations_N>(n1.ID); n2 = reloadCtx.Find<One_to_N_relations_N>(n2.ID); }
private void CreateTestData() { { srvCtx = scope.Resolve<IZetboxServerContext>(); var grpAdmin = Zetbox.NamedObjects.Base.Groups.Administrator.Find(srvCtx); var grpEveryOne = Zetbox.NamedObjects.Base.Groups.Everyone.Find(srvCtx); // Create Identities admin = srvCtx.Create<Identity>(); admin.DisplayName = "Administrator"; admin.UserName = "******"; admin.Groups.Add(grpAdmin); admin.Groups.Add(grpEveryOne); identity1 = srvCtx.Create<Identity>(); identity1.DisplayName = "User 1"; identity1.UserName = "******"; identity1.Groups.Add(grpEveryOne); identity2 = srvCtx.Create<Identity>(); identity2.DisplayName = "User 2"; identity2.UserName = "******"; identity2.Groups.Add(grpEveryOne); identity3_low = srvCtx.Create<Identity>(); identity3_low.DisplayName = "User 3 with low privileges"; identity3_low.UserName = "******"; ma1 = srvCtx.Create<Mitarbeiter>(); ma1.Name = identity1.DisplayName; ma1.Identity = identity1; ma2 = srvCtx.Create<Mitarbeiter>(); ma2.Name = identity2.DisplayName; ma2.Identity = identity2; ma3_low = srvCtx.Create<Mitarbeiter>(); ma3_low.Name = identity3_low.DisplayName; ma3_low.Identity = identity3_low; srvCtx.SubmitChanges(); } { // Create 3 identity context var ctx = scope.Resolve<ServerZetboxContextFactory>().Invoke(identity1); // Create TestData with Identity 1 prj1 = ctx.Create<Projekt>(); prj1.Name = "Project User 1"; prj1.Mitarbeiter.Add(ctx.Find<Mitarbeiter>(ma1.ID)); CreateTasks(ctx, prj1); // Create TestData with Identity 1, common prjCommon = ctx.Create<Projekt>(); prjCommon.Name = "Project Common"; prjCommon.Mitarbeiter.Add(ctx.Find<Mitarbeiter>(ma1.ID)); prjCommon.Mitarbeiter.Add(ctx.Find<Mitarbeiter>(ma2.ID)); CreateTasks(ctx, prjCommon); ctx.SubmitChanges(); prj1ID = prj1.ID; prjCommonID = prjCommon.ID; } { var ctx = scope.Resolve<ServerZetboxContextFactory>().Invoke(identity2); // Create TestData with Identity 2 prj2 = ctx.Create<Projekt>(); prj2.Name = "Project User 2"; prj2.Mitarbeiter.Add(ctx.Find<Mitarbeiter>(ma2.ID)); CreateTasks(ctx, prj2); ctx.SubmitChanges(); prj2ID = prj2.ID; } id1Ctx = scope.Resolve<ServerZetboxContextFactory>().Invoke(identity1); id2Ctx = scope.Resolve<ServerZetboxContextFactory>().Invoke(identity2); id3Ctx_low = scope.Resolve<ServerZetboxContextFactory>().Invoke(identity3_low); prj1 = id1Ctx.Find<Projekt>(prj1ID); prjCommon = id1Ctx.Find<Projekt>(prjCommonID); prj2 = id2Ctx.Find<Projekt>(prj2ID); // Fix security tables // Own test checks if this works during object modifications too var connectionString = config.Server.GetConnectionString(Helper.ZetboxConnectionStringKey); using (var db = scope.ResolveNamed<ISchemaProvider>(connectionString.SchemaProvider)) { db.Open(connectionString.ConnectionString); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Projekte")); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Tasks")); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Auftraege")); } }
public void Find_T_should_return_correct_item() { int targetId = 1; TestObjClass obj = ctx.Find <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)); }
private void CreateTestData() { { srvCtx = scope.Resolve <IZetboxServerContext>(); var grpAdmin = Zetbox.NamedObjects.Base.Groups.Administrator.Find(srvCtx); var grpEveryOne = Zetbox.NamedObjects.Base.Groups.Everyone.Find(srvCtx); // Create Identities admin = srvCtx.Create <Identity>(); admin.DisplayName = "Administrator"; admin.UserName = "******"; admin.Groups.Add(grpAdmin); admin.Groups.Add(grpEveryOne); identity1 = srvCtx.Create <Identity>(); identity1.DisplayName = "User 1"; identity1.UserName = "******"; identity1.Groups.Add(grpEveryOne); identity2 = srvCtx.Create <Identity>(); identity2.DisplayName = "User 2"; identity2.UserName = "******"; identity2.Groups.Add(grpEveryOne); identity3_low = srvCtx.Create <Identity>(); identity3_low.DisplayName = "User 3 with low privileges"; identity3_low.UserName = "******"; ma1 = srvCtx.Create <Mitarbeiter>(); ma1.Name = identity1.DisplayName; ma1.Identity = identity1; ma2 = srvCtx.Create <Mitarbeiter>(); ma2.Name = identity2.DisplayName; ma2.Identity = identity2; ma3_low = srvCtx.Create <Mitarbeiter>(); ma3_low.Name = identity3_low.DisplayName; ma3_low.Identity = identity3_low; srvCtx.SubmitChanges(); } { // Create 3 identity context var ctx = scope.Resolve <ServerZetboxContextFactory>().Invoke(identity1); // Create TestData with Identity 1 prj1 = ctx.Create <Projekt>(); prj1.Name = "Project User 1"; prj1.Mitarbeiter.Add(ctx.Find <Mitarbeiter>(ma1.ID)); CreateTasks(ctx, prj1); // Create TestData with Identity 1, common prjCommon = ctx.Create <Projekt>(); prjCommon.Name = "Project Common"; prjCommon.Mitarbeiter.Add(ctx.Find <Mitarbeiter>(ma1.ID)); prjCommon.Mitarbeiter.Add(ctx.Find <Mitarbeiter>(ma2.ID)); CreateTasks(ctx, prjCommon); ctx.SubmitChanges(); prj1ID = prj1.ID; prjCommonID = prjCommon.ID; } { var ctx = scope.Resolve <ServerZetboxContextFactory>().Invoke(identity2); // Create TestData with Identity 2 prj2 = ctx.Create <Projekt>(); prj2.Name = "Project User 2"; prj2.Mitarbeiter.Add(ctx.Find <Mitarbeiter>(ma2.ID)); CreateTasks(ctx, prj2); ctx.SubmitChanges(); prj2ID = prj2.ID; } id1Ctx = scope.Resolve <ServerZetboxContextFactory>().Invoke(identity1); id2Ctx = scope.Resolve <ServerZetboxContextFactory>().Invoke(identity2); id3Ctx_low = scope.Resolve <ServerZetboxContextFactory>().Invoke(identity3_low); prj1 = id1Ctx.Find <Projekt>(prj1ID); prjCommon = id1Ctx.Find <Projekt>(prjCommonID); prj2 = id2Ctx.Find <Projekt>(prj2ID); // Fix security tables // Own test checks if this works during object modifications too var connectionString = config.Server.GetConnectionString(Helper.ZetboxConnectionStringKey); using (var db = scope.ResolveNamed <ISchemaProvider>(connectionString.SchemaProvider)) { db.Open(connectionString.ConnectionString); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Projekte")); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Tasks")); db.ExecRefreshRightsOnProcedure(db.GetProcedureName("projekte", "RefreshRightsOn_Auftraege")); } }