Exemplo n.º 1
0
        public void CreateValidAccounts()
        {
            RunTestMethod(() => {
                // Add customer records
                IDataPortalResult result    = null;
                DataTable customerDataTable = DataTableFactory.Customer();

                customerDataTable.AddCustomerRow(code: "AAA");
                customerDataTable.AddCustomerRow(code: "BBB");

                result = DataPortal.Persist__Customer(customerDataTable);

                // Add account records for each customer
                DataTable accountDataTable = DataTableFactory.Account();

                long customerID = (long)customerDataTable.Rows[0]["CustomerID"];
                accountDataTable.AddAccountRow(customerID: customerID, code: "AAA");
                accountDataTable.AddAccountRow(customerID: customerID, code: "BBB");

                customerID = (long)customerDataTable.Rows[1]["CustomerID"];
                accountDataTable.AddAccountRow(customerID: customerID, code: "AAA");
                accountDataTable.AddAccountRow(customerID: customerID, code: "BBB");

                result = DataPortal.Persist__Account(accountDataTable);

                // Assertions
                Assert.True(result.OK, $"Database operation returned error: {result.FirstErrorMessage}");
                Assert.Equal(4, result.RowsUpdated);
            });
        }
Exemplo n.º 2
0
        private void QueryCompleted(object sender, EventArgs e)
        {
            IDataPortalResult eventArgs = e as IDataPortalResult;

            _runningQuery = true;
            SetError(eventArgs.Error);
            ObjectInstance = eventArgs.Object;
            RefreshCanOperationsValues();
            _runningQuery = false;
            this.IsBusy   = false;
        }
        protected virtual bool HasNoException(IDataPortalResult result)
        {
            bool returnValue = (result.Error == null);

            if (!returnValue)
            {
                //TODO: log errors
                MessageBox.Show(result.Error.Message, "Rolodex", MessageBoxButton.OK);
            }
            return(returnValue);
        }
Exemplo n.º 4
0
        public void CreateCustomersWithSameName()
        {
            RunTestMethod(() => {
                DataTable customerDataTable = DataTableFactory.Customer(includeConstraints: false);

                customerDataTable.AddCustomerRow(code: "AAA", customer: "AAA");
                customerDataTable.AddCustomerRow(code: "BBB", customer: "AAA");

                IDataPortalResult result = DataPortal.Persist__Customer(customerDataTable);

                Assert.False(result.OK);
            });
        }
Exemplo n.º 5
0
        public void CreateValidCustomers()
        {
            RunTestMethod(() => {
                DataTable customerDataTable = DataTableFactory.Customer();

                customerDataTable.AddCustomerRow(code: "AAA");
                customerDataTable.AddCustomerRow(code: "BBB");

                IDataPortalResult result = DataPortal.Persist__Customer(customerDataTable);

                Assert.True(result.OK, $"Database operation returned error: {result.FirstErrorMessage}");
                Assert.Equal(2, result.RowsUpdated);
            });
        }
Exemplo n.º 6
0
        public void CreateDatabase()
        {
            DataTableFactory  dataTableFactory = new DataTableFactory();
            IDataPortalResult result           = null;

            #region Create Customers

            DataTable customerDataTable = dataTableFactory.Customer();

            for (int customerIndex = 1; customerIndex <= 100; customerIndex++)
            {
                customerDataTable.AddCustomerRow(code: $"{customerIndex.ToString().PadLeft(4, '0')}");
            }

            result = DataPortal.Persist__Customer(customerDataTable);

            Assert.True(result.OK, $"Database operation returned error: {result.FirstErrorMessage}");
            Assert.Equal(100, result.RowsUpdated);

            #endregion

            #region Create Accounts

            DataTable accountDataTable = dataTableFactory.Account();

            foreach (DataRow parentDataRow in customerDataTable.Rows)
            {
                for (int accountIndex = 1; accountIndex <= 3; accountIndex++)
                {
                    accountDataTable.AddAccountRow(customerID: (long)parentDataRow["CustomerID"], code: $"{accountIndex.ToString().PadLeft(4, '0')}");
                }
            }

            result = DataPortal.Persist__Account(accountDataTable);

            Assert.True(result.OK, $"Database operation returned error: {result.FirstErrorMessage}");
            Assert.Equal(300, result.RowsUpdated);

            #endregion
        }
Exemplo n.º 7
0
    void LoaderComplete(IAsyncLoader loader, IDataPortalResult e)
    {
      // remove from loading list 
      lock (_syncRoot)
      {
        _loading.Remove(loader);
      }

      // no error then load new property value and notify property changed
      if (e.Error == null) 
      {
        _target.LoadProperty(loader.Property, e.Object);
        _onPropertyChanged(loader.Property);
      }

      // mark property as not busy 
      OnPropertyBusy(loader.Property.Name, false);

      // if error raise OnUnhandledAsyncException event
      if (e.Error != null) 
        OnUnhandledAsyncException(this, new AsyncLoadException(loader.Property,string.Format(Resources.AsyncLoadException, loader.Property.FriendlyName), e.Error));
    }
Exemplo n.º 8
0
        public void CreateAccountsWithSameCustomerIDAndName()
        {
            RunTestMethod(() => {
                // Add customer record
                IDataPortalResult result    = null;
                DataTable customerDataTable = DataTableFactory.Customer();

                customerDataTable.AddCustomerRow(code: "AAA");

                result = DataPortal.Persist__Customer(customerDataTable);

                // Add account records for customer with matching name
                DataTable accountDataTable = DataTableFactory.Account(includeConstraints: false);

                long customerID = (long)customerDataTable.Rows[0]["CustomerID"];
                accountDataTable.AddAccountRow(customerID: customerID, code: "AAA", account: "AAA");
                accountDataTable.AddAccountRow(customerID: customerID, code: "BBB", account: "AAA");

                result = DataPortal.Persist__Account(accountDataTable);

                Assert.False(result.OK);
            });
        }
Exemplo n.º 9
0
        void LoaderComplete(IAsyncLoader loader, IDataPortalResult e)
        {
            // remove from loading list
            lock (_syncRoot)
            {
                _loading.Remove(loader);
            }

            // no error then load new property value and notify property changed
            if (e.Error == null)
            {
                _target.LoadProperty(loader.Property, e.Object);
                _onPropertyChanged(loader.Property);
            }

            // mark property as not busy
            OnPropertyBusy(loader.Property.Name, false);

            // if error raise OnUnhandledAsyncException event
            if (e.Error != null)
            {
                OnUnhandledAsyncException(this, new AsyncLoadException(loader.Property, string.Format(Resources.AsyncLoadException, loader.Property.FriendlyName), e.Error));
            }
        }
        /// <summary>Searches the items loaded.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="result">The result.</param>
        private void SearchItemsLoaded(object sender, IDataPortalResult result)
        {
            try
            {
                if (result.Error != null)
                {
                    Logger.Log(LogSeverity.Error, GetType().FullName, result.Error);
                    ThePopupFactory.NotifyFailure(result.Error);
                }
                else
                {
                    List = (IList)result.Object;

                    if (List != null && List.Count < 1)
                    {
                        OnOK.Invoke(null, null);
                        return;
                    }

                    PopulatePages();
                }
            }
            finally
            {
                IsBusy = false;
            }
        }