public void TestSaveWhileBusy() { #if SILVERLIGHT DataPortal.ProxyTypeName = "Local"; #endif UnitTestContext context = GetContext(); ItemWithAsynchRule item; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { item = e.Object; context.Assert.IsNull(e.Error); context.Assert.IsNotNull(item); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy); context.Assert.IsFalse(item.IsSavable); item.BeginSave((o1, e1) => { var error = e1.Error as InvalidOperationException; context.Assert.IsNotNull(error); if (error != null) { context.Assert.IsTrue(error.Message.ToLower().Contains("busy")); } context.Assert.IsTrue(error.Message.ToLower().Contains("save")); context.Assert.Success(); }); }); context.Complete(); }
public void TestSaveWhileNotBusyNetOnly() { UnitTestContext context = GetContext(); System.Configuration.ConfigurationManager.AppSettings["CslaAutoCloneOnUpdate"] = "false"; ItemWithAsynchRule item; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { item = e.Object; context.Assert.IsNull(e.Error); context.Assert.IsNotNull(item); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy); context.Assert.IsFalse(item.IsSavable); item.ValidationComplete += (o2, e2) => { context.Assert.IsFalse(item.IsBusy); context.Assert.IsTrue(item.IsSavable); item = item.Save(); context.Assert.AreEqual("DataPortal_Update", item.OperationResult); context.Assert.Success(); }; }); context.Complete(); }
public void TestBusy() { #if SILVERLIGHT DataPortal.ProxyTypeName = "Local"; #else System.Configuration.ConfigurationManager.AppSettings["CslaAutoCloneOnUpdate"] = "false"; #endif UnitTestContext context = GetContext(); ItemWithAsynchRule item; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { try { item = e.Object; context.Assert.IsNull(e.Error, "Error should be null"); context.Assert.IsNotNull(item, "item should not be null"); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy, "Should be busy"); context.Assert.IsFalse(item.IsSavable, "Should not be savable"); } catch (Exception ex) { context.Assert.Fail(ex.ToString()); } context.Assert.Success(); }); context.Complete(); }
public void TestSaveWhileBusyNetOnly() { UnitTestContext context = GetContext(); ItemWithAsynchRule item; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { item = e.Object; context.Assert.IsNull(e.Error); context.Assert.IsNotNull(item); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy); context.Assert.IsFalse(item.IsSavable); bool gotError = false; try { item.Save(); } catch (InvalidOperationException EX) { gotError = true; } context.Assert.IsTrue(gotError); context.Assert.Success(); }); context.Complete(); }
public void TestNotBusy() { #if SILVERLIGHT DataPortal.ProxyTypeName = "Local"; #endif UnitTestContext context = GetContext(); ItemWithAsynchRule item; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { item = e.Object; context.Assert.IsNull(e.Error); context.Assert.IsNotNull(item); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy); context.Assert.IsFalse(item.IsSavable); item.ValidationComplete += (o2, e2) => { context.Assert.IsFalse(item.IsBusy); context.Assert.IsTrue(item.IsSavable); context.Assert.Success(); }; }); context.Complete(); }
public void TestSaveWhileNotBusy() { #if SILVERLIGHT DataPortal.ProxyTypeName = "Local"; #endif UnitTestContext context = GetContext(); context.Assert.Try(() => { ItemWithAsynchRule item; bool saving = false; ItemWithAsynchRule.GetItemWithAsynchRule("an id", (o, e) => { item = e.Object; context.Assert.IsNull(e.Error); context.Assert.IsNotNull(item); context.Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Client, Csla.ApplicationContext.LogicalExecutionLocation); item.RuleField = "some value"; context.Assert.IsTrue(item.IsBusy, "IsBusy should be true"); context.Assert.IsFalse(item.IsSavable, "IsSavable"); item.ValidationComplete += (o2, e2) => { context.Assert.IsFalse(item.IsRunningRules, "IsRunningRules"); lock (item) { if (!saving) { saving = true; context.Assert.IsTrue(item.IsSavable, "IsSavable should be true"); item.BeginSave((o4, e4) => { context.Assert.IsNull(e4.Error); context.Assert.IsNotNull(e4.NewObject); var newItem = (ItemWithAsynchRule)e4.NewObject; if (newItem != null) { context.Assert.AreEqual("DataPortal_Update", newItem.OperationResult); } context.Assert.Success(); }); } } }; }); }); context.Complete(); }