예제 #1
0
 public void AddCreditCardsToCustomer()
 {
     var mockLogger = new Mock<ILogger>();
     var settings = GetPopulatedSettingsObj();
     var repo = new QBRepository(mockLogger.Object, settings);
     var cust = GetPopulatedCustomer();
     cust.CreditCards[0].CardholderName = RandomString(10);
     cust.CreditCards[0].CardNumber = GetRandomNumber(100, 200).ToString();
     repo.AddCreditCardsForCustomer(cust.CreditCards, "80002E4E-1279074492");
     var custAfter = repo.GetCustomerByID("80002E4E-1279074492");
     Assert.IsTrue(cust.CreditCards[0].CardholderName == custAfter.CreditCards[0].CardholderName);
 }
예제 #2
0
        public frmMain(ILogger logger, QBRepository qbRepo, ISettings settings, frmCustomerSearch fCustSearch, IFileSystemRepository fsRepo, SalesItemsRepository salesItemsRepo)
        {
            InitializeComponent();

            try
            {
                _ucContacts = ucGridContacts;
                _ucSwatchOrders = ucSwatches;
                _ucPendingOrders = ucGridPendingOrders;

                _logger = logger;
                _qbRepo = qbRepo;
                _settings = settings;
                _fCustomerSearch = fCustSearch;
                _fsRepo = fsRepo;
                _salesItemsRepository = salesItemsRepo;

                _fCustomerSearch.Text = "QuickBooks Customers";

                if (_settings.IsInitialStartup)
                {
                    ShowSettingsForm();
                }

                LoadCboPendingSince();

                TestForQuickBooksConnection();

                SetConnectionBasedUiElements();

                CacheSalesItemsFromAppConfigFile();

            }
            catch (Exception ex)
            {
                _logger.LogException("There was an error in frmMain load.", ex);
                MessageBox.Show("There was an error on application startup (see the log for details).  The error may be related to incorrect settings.  The settings are located under View > Settings.", "Error",  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 public void AddCreditCardsWithNewCustomer()
 {
     var custOrig = this.GetPopulatedCustomer();
     var mockLogger = new Mock<ILogger>();
     var settings = GetPopulatedSettingsObj();
     var repo = new QBRepository(mockLogger.Object, settings);
                 var id = repo.AddCustomer(custOrig);
     var cust = repo.GetCustomerByID(id);
     Assert.IsTrue(cust.CreditCards[0].CardholderName == custOrig.CreditCards[0].CardholderName);
 }
예제 #4
0
        public void SaveInvoice_NewCustomer()
        {
            var cust = GetPopulatedCustomer();
            string custName = cust.FullName;
            CustomerOrderObject coo = new CustomerOrderObject()
            {
                Customer =  cust,
                Order = new Order()
                {
                    OrderDate = DateTime.Now,
                    OrderItems = new List<OrderItem>()
                    {
                        new OrderItem(){
                             ItemID  = "8000005C-1213652981",
                              IsTaxed = false,
                               Description = "test desc",
                                Quantity = 5,
                                 Price  = 10

                        }
                    }
                }
            };

            ISettings s = GetPopulatedSettingsObj();

            var mockLogger = new Mock<ILogger>();

            var repo = new QBRepository(mockLogger.Object, s);
            repo.SaveInvoice(coo);

            var custs = repo.SearchCustomers(custName);
            Assert.IsTrue(custs[0].CreditCards[0].IsUsed);
        }
예제 #5
0
        public void ModifyCreditCardInfo()
        {
            string cholderName = RandomString(10);
            string cardnum = GetRandomNumber(1000, 999999).ToString();
            string expiration = GetRandomDay().ToShortDateString();
            string note = RandomString(10);

            var mockLogger = new Mock<ILogger>();
            var settings = GetPopulatedSettingsObj();
            var repo = new QBRepository(mockLogger.Object, settings);
            var existingCustomer = repo.GetCustomerByID("80002E4C-1279071429");
            var newCardType = ChangeCreditCardType(existingCustomer.CreditCards[1].CreditCardType);
            existingCustomer.CreditCards[1].CreditCardType = newCardType;
            existingCustomer.CreditCards[1].CardholderName = cholderName;
            existingCustomer.CreditCards[1].CardNumber = cardnum;
            existingCustomer.CreditCards[1].ExpirationDate = expiration;
            existingCustomer.CreditCards[1].Note = note;

            repo.ModifyCreditCardsForCustomer(existingCustomer.CreditCards, existingCustomer.CustomerID);

            var modifiedCust = repo.GetCustomerByID("80002E4C-1279071429");

            Assert.IsTrue(cholderName == modifiedCust.CreditCards[1].CardholderName);
            Assert.IsTrue(cardnum == modifiedCust.CreditCards[1].CardNumber);
            Assert.IsTrue(expiration == modifiedCust.CreditCards[1].ExpirationDate);
            Assert.IsTrue(newCardType == modifiedCust.CreditCards[1].CreditCardType);
        }
예제 #6
0
 public void GetAllSalesItems()
 {
     var mockLogger = new Mock<ILogger>();
     var settings= GetPopulatedSettingsObj();
     var repo = new QBRepository(mockLogger.Object, settings);
     var allItems = repo.GetAllSalesItems(true);
     Assert.IsTrue(allItems.Count == 36);
 }
예제 #7
0
 public void AddCustomer()
 {
     var mockLogger = new Mock<ILogger>();
     var settings = GetPopulatedSettingsObj();
     var repo = new QBRepository(mockLogger.Object, settings);
     var id = repo.AddCustomer(this.GetPopulatedCustomer());
     var cust = repo.GetCustomerByID(id);
     Assert.IsTrue(cust != null);
 }