public void RemoveNewItem() { UnitTestContext context = GetContext(); DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName; WcfProxy.DefaultUrl = cslalighttest.Properties.Resources.RemotePortalUrl; ApplicationContext.GlobalContext.Clear(); RootSingleItemsList list; RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) => { context.Assert.IsNotNull(e.Object); list = e.Object; SingleItem item = SingleItem.GetSingleItem(); list.Add(item); context.Assert.AreEqual(3, list.Count, "Count should be 3"); context.Assert.IsTrue(list[2].IsNew, "Object should be new"); list.RemoveAt(2); context.Assert.AreEqual(2, list.Count, "Incorrect count after remove"); context.Assert.AreEqual(false, item.MethodCalled == "DataPortal_DeleteSelf", "Should not have deleted new item"); context.Assert.IsTrue(item.IsNew, "Object should be new after delete"); context.Assert.Success(); } ); context.Complete(); }
public void AddItem() { UnitTestContext context = GetContext(); DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName; WcfProxy.DefaultUrl = cslalighttest.Properties.Resources.RemotePortalUrl; ApplicationContext.GlobalContext.Clear(); RootSingleItemsList list; RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) => { if (e.Error != null) { context.Assert.Fail(e.Error.Message); } else { context.Assert.IsNotNull(e.Object); list = e.Object; SingleItem item = SingleItem.GetSingleItem(); list.Add(item); context.Assert.AreEqual(3, list.Count, "Count should be 3"); context.Assert.IsTrue(list[2].IsNew, "Object should be new"); } context.Assert.Success(); } ); context.Complete(); }
public void UpdateItemViaListSavedEvent() { UnitTestContext context = GetContext(); DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName; WcfProxy.DefaultUrl = cslalighttest.Properties.Resources.RemotePortalUrl; ApplicationContext.GlobalContext.Clear(); RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) => { context.Assert.Try(() => { context.Assert.IsNotNull(e.Object); RootSingleItemsList list = e.Object; context.Assert.AreEqual(2, list.Count, "Count should be 2"); list.Saved += (o1, e1) => { context.Assert.IsNull(e1.Error); context.Assert.AreEqual(2, list.Count, "Incorrect count after remove"); context.Assert.AreEqual("DataPortal_Update", ((SingleItem)e1.NewObject).MethodCalled, "Object should have been updated"); context.Assert.IsFalse(list[0].IsDirty, "Object should not be dirty"); context.Assert.Success(); }; // simulate grid edit SingleItem item = list[0]; IEditableObject obj = (IEditableObject)item; obj.BeginEdit(); item.Name = "test"; obj.EndEdit(); }); }); context.Complete(); }
public void BusyImplemented() { UnitTestContext context = GetContext(); DataPortal.ProxyTypeName = typeof(SynchronizedWcfProxy).AssemblyQualifiedName; WcfProxy.DefaultUrl = cslalighttest.Properties.Resources.RemotePortalUrl; ApplicationContext.GlobalContext.Clear(); RootSingleItemsList.GetRootSingleItemsList(1, 2, (o, e) => { context.Assert.IsFalse(e.Object.IsBusy); context.Assert.Success(); }); context.Complete(); }
private void Login_Click(object sender, RoutedEventArgs e) { LoginStatus.Text = "Logging in..."; BusinessPrincipal.Login("SergeyB", "1234", "admin;user", (objectValue, eventArgs) => { if (Csla.ApplicationContext.User.Identity.IsAuthenticated) { LoginStatus.Text = "Logged in as " + Csla.ApplicationContext.User.Identity.Name; ItemsGrid.Visibility = Visibility.Visible; LoginStatus.Text = "Getting items..."; RootSingleItemsList.GetRootSingleItemsList(1, 100, (o, ef) => { if (ef.Error != null) { LoginStatus.Text = "Error getting items list"; } else { ItemsGrid.ItemsSource = ef.Object; LoginStatus.Text = "Got data."; _currentList = ef.Object; _currentList.Saved += (o1, e1) => { if (e1.Error == null) { Status.Text = "Saved item " + ((SingleItem)e1.NewObject).Id.ToString(); } else { Status.Text = "Could not save item " + ((SingleItem)e1.NewObject).Id.ToString() + ". Error: " + e1.Error.ToString(); } }; if (_currentList.Count > 0) { ItemsGrid.SelectedItem = _currentList[0]; } } }); } else { LoginStatus.Text = "Login failed"; } }); }