public void GlobalContext() { Csla.ApplicationContext.GlobalContext.Clear(); ApplicationContext.GlobalContext["globalcontext"] = "global context data"; Assert.AreEqual("global context data", ApplicationContext.GlobalContext["globalcontext"], "first"); Csla.Test.Basic.Root root = Csla.Test.Basic.Root.NewRoot(); root.Data = "saved"; Assert.AreEqual("saved", root.Data); Assert.AreEqual(true, root.IsDirty); Assert.AreEqual(true, root.IsValid); Csla.ApplicationContext.GlobalContext.Clear(); root = root.Save(); Assert.IsNotNull(root); //Assert.IsNotNull(Thread.GetData(Thread.GetNamedDataSlot("Csla.GlobalContext"))); Assert.AreEqual("Inserted", Csla.ApplicationContext.GlobalContext["Root"]); Assert.AreEqual("saved", root.Data); Assert.AreEqual(false, root.IsNew); Assert.AreEqual(false, root.IsDeleted); Assert.AreEqual(false, root.IsDirty); Assert.AreEqual("new global value", ApplicationContext.GlobalContext["globalcontext"], "Second"); }
public void ClientContext() { Csla.ApplicationContext.GlobalContext.Clear(); Csla.ApplicationContext.ClientContext.Add("clientcontext", "client context data"); Assert.AreEqual("client context data", Csla.ApplicationContext.ClientContext["clientcontext"], "Matching data not retrieved"); Csla.Test.Basic.Root root = Csla.Test.Basic.Root.NewRoot(); root.Data = "saved"; Assert.AreEqual("saved", root.Data, "Root data should be 'saved'"); Assert.AreEqual(true, root.IsDirty, "Object should be dirty"); Assert.AreEqual(true, root.IsValid, "Object should be valid"); Csla.ApplicationContext.GlobalContext.Clear(); root = root.Save(); Assert.IsNotNull(root, "Root object should not be null"); Assert.AreEqual("Inserted", Csla.ApplicationContext.GlobalContext["Root"], "Object not inserted"); Assert.AreEqual("saved", root.Data, "Root data should be 'saved'"); Assert.AreEqual(false, root.IsNew, "Object should not be new"); Assert.AreEqual(false, root.IsDeleted, "Object should not be deleted"); Assert.AreEqual(false, root.IsDirty, "Object should not be dirty"); Assert.AreEqual("client context data", Csla.ApplicationContext.ClientContext["clientcontext"], "Client context data lost"); Assert.AreEqual("client context data", Csla.ApplicationContext.GlobalContext["clientcontext"], "Global context data lost"); Assert.AreEqual("new global value", Csla.ApplicationContext.GlobalContext["globalcontext"], "New global value lost"); }
public void DeleteNewRoot() { Csla.ApplicationContext.GlobalContext.Clear(); Csla.Test.Basic.Root root = Csla.Test.Basic.Root.NewRoot(); Csla.ApplicationContext.GlobalContext.Clear(); root.Delete(); Assert.AreEqual(true, root.IsNew); Assert.AreEqual(true, root.IsDeleted); Assert.AreEqual(true, root.IsDirty); root = root.Save(); Assert.IsNotNull(root); Assert.AreEqual(null, Csla.ApplicationContext.GlobalContext["Root"]); Assert.AreEqual(true, root.IsNew); Assert.AreEqual(false, root.IsDeleted); Assert.AreEqual(true, root.IsDirty); }
public void DeleteNewRoot() { TestResults.Reinitialise(); Csla.Test.Basic.Root root = NewRoot(); TestResults.Reinitialise(); root.Delete(); Assert.AreEqual(true, root.IsNew); Assert.AreEqual(true, root.IsDeleted); Assert.AreEqual(true, root.IsDirty); root = root.Save(); Assert.IsNotNull(root); Assert.AreEqual("", TestResults.GetResult("Root")); Assert.AreEqual(true, root.IsNew); Assert.AreEqual(false, root.IsDeleted); Assert.AreEqual(true, root.IsDirty); }
public void SaveOldRoot() { Csla.ApplicationContext.GlobalContext.Clear(); Csla.Test.Basic.Root root = Csla.Test.Basic.Root.GetRoot("old"); root.Data = "saved"; Assert.AreEqual("saved", root.Data); Assert.AreEqual(true, root.IsDirty, "IsDirty"); Assert.AreEqual(true, root.IsValid, "IsValid"); Csla.ApplicationContext.GlobalContext.Clear(); root = root.Save(); Assert.IsNotNull(root); Assert.AreEqual("Updated", Csla.ApplicationContext.GlobalContext["Root"]); Assert.AreEqual("saved", root.Data); Assert.AreEqual(false, root.IsNew, "IsNew"); Assert.AreEqual(false, root.IsDeleted, "IsDeleted"); Assert.AreEqual(false, root.IsDirty, "IsDirty"); }
public void SaveOldRoot() { TestResults.Reinitialise(); Csla.Test.Basic.Root root = GetRoot("old"); root.Data = "saved"; Assert.AreEqual("saved", root.Data); Assert.AreEqual(true, root.IsDirty, "IsDirty"); Assert.AreEqual(true, root.IsValid, "IsValid"); TestResults.Reinitialise(); root = root.Save(); Assert.IsNotNull(root); Assert.AreEqual("Updated", TestResults.GetResult("Root")); Assert.AreEqual("saved", root.Data); Assert.AreEqual(false, root.IsNew, "IsNew"); Assert.AreEqual(false, root.IsDeleted, "IsDeleted"); Assert.AreEqual(false, root.IsDirty, "IsDirty"); }
public void SaveNewRoot() { Csla.ApplicationContext.GlobalContext.Clear(); Csla.Test.Basic.Root root = Csla.Test.Basic.Root.NewRoot(); root.Data = "saved"; Assert.AreEqual("saved", root.Data); Assert.AreEqual(true, root.IsDirty); Assert.AreEqual(true, root.IsValid); Csla.ApplicationContext.GlobalContext.Clear(); root = root.Save(); Assert.IsNotNull(root); //fails because no call is being made to DataPortal_Insert in Root.DataPortal_Update if IsDeleted == false and IsNew == true Assert.AreEqual("Inserted", Csla.ApplicationContext.GlobalContext["Root"]); Assert.AreEqual("saved", root.Data); Assert.AreEqual(false, root.IsNew, "IsNew"); Assert.AreEqual(false, root.IsDeleted, "IsDeleted"); Assert.AreEqual(false, root.IsDirty, "IsDirty"); }
public void SaveNewRoot() { TestResults.Reinitialise(); Csla.Test.Basic.Root root = NewRoot(); root.Data = "saved"; Assert.AreEqual("saved", root.Data); Assert.AreEqual(true, root.IsDirty); Assert.AreEqual(true, root.IsValid); TestResults.Reinitialise(); root = root.Save(); Assert.IsNotNull(root); //fails because no call is being made to DataPortal_Insert in Root.DataPortal_Update if IsDeleted == false and IsNew == true Assert.AreEqual("Inserted", TestResults.GetResult("Root")); Assert.AreEqual("saved", root.Data); Assert.AreEqual(false, root.IsNew, "IsNew"); Assert.AreEqual(false, root.IsDeleted, "IsDeleted"); Assert.AreEqual(false, root.IsDirty, "IsDirty"); }