public void Clears_List_But_Not_Store()
 {
     _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);
       _biggyMemoryList.Clear();
       var storeWidgets = _widgetStore.Load();
       Assert.True(_biggyMemoryList.Count() == 0 && storeWidgets.Count == INSERT_QTY);
 }
Example #2
0
        public BiggyListWithFileDb()
        {
            // Set up the store for injection:
              _widgets = new JsonStore<Widget>(dbName: "widgets");
              _widgets.Clear();

              _biggyWidgetList = new Biggy.BiggyList<Widget>(_widgets);
        }
        public void Adds_Item_To_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);
              _biggyMemoryList.Add(new Widget { SKU = "1000", Name = "Test widget 1", Price = 2.00M });
              var storeWidgets = _widgetStore.Load();

              var addedItem = _biggyMemoryList.FirstOrDefault(w => w.SKU == "001");
              Assert.True(addedItem != null && _biggyMemoryList.Count() == INSERT_QTY + 1 && storeWidgets.Count() == INSERT_QTY);
        }
Example #4
0
        public BiggyListWithFileDb()
        {
            // Set up the store for injection:
              _widgets = new JsonStore<Widget>(dbName: "widgets");
              _updateableWidgets = _widgets as IUpdateableBiggyStore<Widget>;
              _queryableWidgets = _widgets as IQueryableBiggyStore<Widget>;
              _widgets.Clear();

              _biggyWidgetList = new Biggy.BiggyList<Widget>(_widgets);
        }
Example #5
0
        public void Adds_Item_To_List_And_Store()
        {
            _biggyWidgetList.Clear();
              _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M });

              // Reload the list:
              _biggyWidgetList = new BiggyList<Widget>(_widgets);
              var addedItem = _biggyWidgetList.FirstOrDefault(w => w.SKU == "001");
              Assert.True(addedItem != null && _biggyWidgetList.Count() == 1);
        }
 public BiggyListWithSQLDocuments()
 {
     // This one will be re-created automagically:
       if (dbCache.TableExists("ClientDocuments")) {
     dbCache.DropTable("ClientDocuments");
       }
       // This one will be re-created automagically:
       if (dbCache.TableExists("MonkeyDocuments")) {
     dbCache.DropTable("MonkeyDocuments");
       }
       _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName));
       _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName));
 }
 public BiggyListWithSQLDocuments()
 {
     _host = new SQLServerCache("chinook");
       // This one will be re-created automagically:
       if (_host.TableExists("ClientDocuments")) {
     _host.DropTable("ClientDocuments");
       }
       // This one will be re-created automagically:
       if (_host.TableExists("MonkeyDocuments")) {
     _host.DropTable("MonkeyDocuments");
       }
       _clientDocuments = new BiggyList<ClientDocument>(new SQLDocumentStore<ClientDocument>(_host));
       _monkeyDocuments = new BiggyList<MonkeyDocument>(new SQLDocumentStore<MonkeyDocument>(_host));
 }
 public BiggyListWithPGDocuments()
 {
     var _cache = new PGCache(_connectionStringName);
       // This one will be re-created automagically:
       if (_cache.TableExists("ClientDocuments")) {
     _cache.DropTable("ClientDocuments");
       }
       // This one will be re-created automagically:
       if (_cache.TableExists("MonkeyDocuments")) {
     _cache.DropTable("MonkeyDocuments");
       }
       _clientDocuments = new BiggyList<ClientDocument>(new PGDocumentStore<ClientDocument>(_connectionStringName));
       _monkeyDocuments = new BiggyList<MonkeyDocument>(new PGDocumentStore<MonkeyDocument>(_connectionStringName));
 }
        public void Adds_Batch_Of_Items_To_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);

              int INSERT_QTY = 100;
              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("100{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M });
              }
              _biggyMemoryList.Add(batch);

              // Reload the List:
              var storeWidgets = _widgetStore.Load();
              Assert.True(_biggyMemoryList.Count() == 2 * INSERT_QTY && storeWidgets.Count() == INSERT_QTY);
        }
        public BiggyListWithFileDbInMemory()
        {
            // Set up the store for injection:
              _widgetStore = new JsonStore<Widget>(dbName: "widgets");
              _widgetStore.Clear();

              _biggyMemoryList = new Biggy.BiggyList<Widget>(_widgetStore);

              // Start with some data in a json file:
              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
              }
              _biggyMemoryList.Add(batch);
        }
Example #11
0
        public BiggyListWithPG()
        {
            var _cache = new PGCache(_connectionStringName);
              // Build a table to play with from scratch each time:
              if (_cache.TableExists("client")) {
            _cache.DropTable("client");
              }
              var columnDefs = new List<string>();
              columnDefs.Add("client_id serial PRIMARY KEY NOT NULL");
              columnDefs.Add("last_name Text NOT NULL");
              columnDefs.Add("first_name Text NOT NULL");
              columnDefs.Add("email Text NOT NULL");
              _cache.CreateTable("client", columnDefs);

              _clients = new BiggyList<Client>(new PGStore<Client>(_connectionStringName));
        }
Example #12
0
        public void Adds_Item_To_List_And_Existong_Store()
        {
            _biggyWidgetList.Clear();
            _biggyWidgetList.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });

            // Reload the list:
            _biggyWidgetList = new BiggyList <Widget>(_widgets);
            _biggyWidgetList.Add(new Widget {
                SKU = "002", Name = "Test widget 2", Price = 4.00M
            });

            var addedItem = _biggyWidgetList.FirstOrDefault(w => w.SKU == "001");

            Assert.True(addedItem != null && _biggyWidgetList.Count() == 2);
        }
Example #13
0
        public BiggyListWithSqlCE()
        {
            var context = new SqlCeCache("chinook");
              // Build a table to play with from scratch each time:
              if (context.TableExists("Client")) {
            context.DropTable("Client");
              }

              var columnDefs = new List<string>();
              columnDefs.Add("ClientId int IDENTITY(1,1) PRIMARY KEY NOT NULL");
              columnDefs.Add("LastName nText NOT NULL");
              columnDefs.Add("FirstName nText NOT NULL");
              columnDefs.Add("Email nText NOT NULL");
              context.CreateTable("Client", columnDefs);

              _clients = new BiggyList<Client>(new SqlCeStore<Client>(_connectionStringName));
        }
Example #14
0
        public BiggyListWithSQL()
        {
            _hostDb = new SQLServerCache("chinook");
              // Build a table to play with from scratch each time:
              if (_hostDb.TableExists("Client")) {
            _hostDb.DropTable("Client");
              }

              var columnDefs = new List<string>();
              columnDefs.Add("ClientId int IDENTITY(1,1) PRIMARY KEY NOT NULL");
              columnDefs.Add("LastName Text NOT NULL");
              columnDefs.Add("FirstName Text NOT NULL");
              columnDefs.Add("Email Text NOT NULL");
              _hostDb.CreateTable("Client", columnDefs);

              _clientStore = new SQLServerStore<Client>(_hostDb);
              _clients = new BiggyList<Client>(_clientStore);
        }
        public void Bulk_Inserts_Documents_With_String_PK()
        {
            int INSERT_QTY = 100;

            var addRange = new List <MonkeyDocument>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                addRange.Add(new MonkeyDocument {
                    Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            var inserted = _monkeyDocuments.Add(addRange);

            // Reload, make sure everything was persisted:
            _monkeyDocuments = new BiggyList <MonkeyDocument>(new PGDocumentStore <MonkeyDocument>(_connectionStringName));
            Assert.True(_monkeyDocuments.Count() == INSERT_QTY);
        }
Example #16
0
        public BiggyListWithFileDbInMemory()
        {
            // Set up the store for injection:
            _widgetStore = new JsonStore <Widget>(dbName: "widgets");
            _widgetStore.Clear();

            _biggyMemoryList = new Biggy.BiggyList <Widget>(_widgetStore);

            // Start with some data in a json file:
            var batch = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i
                });
            }
            _biggyMemoryList.Add(batch);
        }
Example #17
0
        public BiggyListWithPG()
        {
            var _cache = new PGCache(_connectionStringName);

            // Build a table to play with from scratch each time:
            if (_cache.TableExists("client"))
            {
                _cache.DropTable("client");
            }
            var columnDefs = new List <string>();

            columnDefs.Add("client_id serial PRIMARY KEY NOT NULL");
            columnDefs.Add("last_name Text NOT NULL");
            columnDefs.Add("first_name Text NOT NULL");
            columnDefs.Add("email Text NOT NULL");
            _cache.CreateTable("client", columnDefs);

            _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName));
        }
Example #18
0
        public void Adds_Batch_Of_Items_To_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true);

            int INSERT_QTY = 100;
            var batch      = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("100{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M
                });
            }
            _biggyMemoryList.Add(batch);

            // Reload the List:
            var storeWidgets = _widgetStore.Load();

            Assert.True(_biggyMemoryList.Count() == 2 * INSERT_QTY && storeWidgets.Count() == INSERT_QTY);
        }
Example #19
0
        public BiggyListWithSQL()
        {
            _hostDb = new SQLServerCache("chinook");
            // Build a table to play with from scratch each time:
            if (_hostDb.TableExists("Client"))
            {
                _hostDb.DropTable("Client");
            }

            var columnDefs = new List <string>();

            columnDefs.Add("ClientId int IDENTITY(1,1) PRIMARY KEY NOT NULL");
            columnDefs.Add("LastName Text NOT NULL");
            columnDefs.Add("FirstName Text NOT NULL");
            columnDefs.Add("Email Text NOT NULL");
            _hostDb.CreateTable("Client", columnDefs);

            _clientStore = new SQLServerStore <Client>(_hostDb);
            _clients     = new BiggyList <Client>(_clientStore);
        }
Example #20
0
        public BiggyListWithSQL()
        {
            var context = new SqlCeCache("chinook");

            // Build a table to play with from scratch each time:
            if (context.TableExists("Client"))
            {
                context.DropTable("Client");
            }

            var columnDefs = new List <string>();

            columnDefs.Add("ClientId int IDENTITY(1,1) PRIMARY KEY NOT NULL");
            columnDefs.Add("LastName nText NOT NULL");
            columnDefs.Add("FirstName nText NOT NULL");
            columnDefs.Add("Email nText NOT NULL");
            context.CreateTable("Client", columnDefs);

            _clients = new BiggyList <Client>(new SqlCeStore <Client>(_connectionStringName));
        }
Example #21
0
        public void Updates_Item_In_List_And_Store()
        {
            _biggyWidgetList.Clear();
            var updateMe = _biggyWidgetList.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });

            // Update and Save:
            updateMe.Name = "UPDATED";
            _biggyWidgetList.Update(updateMe);

            // Reload the list:
            _biggyWidgetList = new BiggyList <Widget>(_widgets);

            // Grab from the list:
            var updatedInList = _biggyWidgetList.FirstOrDefault(w => w.Name == "UPDATED");

            // Make sure updated in both:
            Assert.True(updatedInList.Name == "UPDATED");
        }
        public void Deletes_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
                Email     = "*****@*****.**",
                FirstName = "Rob",
                LastName  = "Conery"
            };

            _clientDocuments.Add(newCustomer);
            // Count after adding new:
            int initialCount = _clientDocuments.Count();
            var removed      = _clientDocuments.Remove(newCustomer);

            // Reload, make sure everything was persisted:
            _clientDocuments = new BiggyList <ClientDocument>(new PGDocumentStore <ClientDocument>(_connectionStringName));
            // Count after removing and reloading:
            int finalCount = _clientDocuments.Count();

            Assert.True(finalCount < initialCount);
        }
        public void Bulk_Inserts_Documents_With_Serial_PK()
        {
            int INSERT_QTY = 100;
              var bulkList = new List<ClientDocument>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClientDocument = new ClientDocument {
              FirstName = "ClientDocument " + i,
              LastName = "Test",
              Email = "*****@*****.**"
            };
            bulkList.Add(newClientDocument);
              }
              _clientDocuments.Add(bulkList);

              // Reload, make sure everything was persisted:
              _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName));

              var last = _clientDocuments.Last();
              Assert.True(_clientDocuments.Count() == INSERT_QTY && last.ClientDocumentId >= INSERT_QTY);
        }
Example #24
0
        public void Updates_Item_From_List_And_Store()
        {
            // Just in case:
            _clients.Clear();
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _clients.Add(newClient);
            _clients = new BiggyList <Client>(new PGStore <Client>(_connectionStringName));
            var updateMe = _clients.FirstOrDefault();

            updateMe.LastName = "Appleseed";
            _clients.Update(updateMe);

            // Open a new instance, to see if the item was added to the backing store as well:
            var altClientList = new BiggyList <Client>(new PGStore <Client>(_connectionStringName));
            var updated       = altClientList.FirstOrDefault(c => c.LastName == "Appleseed");

            Assert.True(updated != null && updated.LastName == "Appleseed");
        }
        public void Bulk_Inserts_Documents_With_Serial_PK()
        {
            int INSERT_QTY = 100;
            var bulkList   = new List <ClientDocument>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                var newClientDocument = new ClientDocument {
                    FirstName = "ClientDocument " + i,
                    LastName  = "Test",
                    Email     = "*****@*****.**"
                };
                bulkList.Add(newClientDocument);
            }
            _clientDocuments.Add(bulkList);

            // Reload, make sure everything was persisted:
            _clientDocuments = new BiggyList <ClientDocument>(new PGDocumentStore <ClientDocument>(_connectionStringName));

            var last = _clientDocuments.Last();

            Assert.True(_clientDocuments.Count() == INSERT_QTY && last.ClientDocumentId >= INSERT_QTY);
        }
Example #26
0
        public void Clears_List_and_Store()
        {
            int INSERT_QTY = 100;

            var addRange = new List <MonkeyDocument>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                addRange.Add(new MonkeyDocument {
                    Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            var inserted = _monkeyDocuments.Add(addRange);

            // Reload, make sure everything was persisted:
            _monkeyDocuments = new BiggyList <MonkeyDocument>(new SQLDocumentStore <MonkeyDocument>(_host));

            _monkeyDocuments.Clear();

            // Reload, make sure everything was persisted:
            _monkeyDocuments = new BiggyList <MonkeyDocument>(new SQLDocumentStore <MonkeyDocument>(_host));

            Assert.True(_monkeyDocuments.Count() == 0);
        }
Example #27
0
        public void Removes_Item_From_List_And_Store()
        {
            _biggyWidgetList.Clear();
              _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M });

              // Reload:
              _biggyWidgetList = new BiggyList<Widget>(_widgets);

              var removeMe = _biggyWidgetList.FirstOrDefault();
              _biggyWidgetList.Remove(removeMe);
              _biggyWidgetList = new BiggyList<Widget>(_widgets);
              Assert.True(_biggyWidgetList.Count() == 0);
        }
Example #28
0
 public SQLDatabase(string connectionStringName) : base(connectionStringName)
 {
     this.Artists = this.CreateBiggyListFor <Artist>();
     this.Albums  = this.CreateBiggyListFor <Album>();
     this.Tracks  = this.CreateBiggyListFor <Track>();
 }
        public void Clears_List_and_Store()
        {
            int INSERT_QTY = 100;

              var addRange = new List<MonkeyDocument>();
              for (int i = 0; i < INSERT_QTY; i++) {
            addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              var inserted = _monkeyDocuments.Add(addRange);

              // Reload, make sure everything was persisted:
              _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName));

              _monkeyDocuments.Clear();

              // Reload, make sure everything was persisted:
              _monkeyDocuments = new BiggyList<MonkeyDocument>(new SqlCeDocumentStore<MonkeyDocument>(_connectionStringName));

              Assert.True(_monkeyDocuments.Count() == 0);
        }
        public void Deletes_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
            Email = "*****@*****.**",
            FirstName = "Rob",
            LastName = "Conery"
              };
              _clientDocuments.Add(newCustomer);
              // Count after adding new:
              int initialCount = _clientDocuments.Count();
              var removed = _clientDocuments.Remove(newCustomer);

              // Reload, make sure everything was persisted:
              _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName));
              // Count after removing and reloading:
              int finalCount = _clientDocuments.Count();
              Assert.True(finalCount < initialCount);
        }
 public void Initializes_List_With_Json_Default_Store()
 {
     _biggyMemoryList = new BiggyList<Widget>();
       _biggyMemoryList.Clear();
       var batch = new List<Widget>();
       for (int i = 0; i < INSERT_QTY; i++) {
     batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
       }
       _biggyMemoryList.Add(batch);
       Assert.True(_biggyMemoryList.Count() == INSERT_QTY);
 }
Example #32
0
        public void Updates_Item_From_List_And_Store()
        {
            // Just in case:
              _clients.Clear();
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _clients.Add(newClient);
              _clients = new BiggyList<Client>(_clientStore);
              var updateMe = _clients.FirstOrDefault();
              updateMe.LastName = "Appleseed";
              _clients.Update(updateMe);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientList = new BiggyList<Client>(new SQLServerStore<Client>(_connectionStringName));
              var updated = altClientList.FirstOrDefault(c => c.LastName == "Appleseed");
              Assert.True(updated != null && updated.LastName == "Appleseed");
        }
Example #33
0
        public void Clears_All_Items_From_List_And_Store()
        {
            int INSERT_QTY = 10;

              // Just in case:
              _clients.Clear();
              var addThese = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            addThese.Add(newClient);
              }
              _clients.Add(addThese);

              // Reload the list:
              _clients = new BiggyList<Client>(_clientStore);
              int loadedCount = _clients.Count();
              _clients.Clear();

              // Reload the list:
              _clients = new BiggyList<Client>(_clientStore);
              int clearedCount = _clients.Count();
              Assert.True(loadedCount == INSERT_QTY && clearedCount == 0);
        }
        public void Initializes_Memory_Only_List_With_True_Argument()
        {
            _biggyMemoryList = new BiggyList<Widget>(inMemory: true);
              var BiggyJsonList = new BiggyList<Widget>();
              _biggyMemoryList.Clear();
              BiggyJsonList.Clear();

              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = i });
              }
              _biggyMemoryList.Add(batch);
              BiggyJsonList.Add(batch);

              int memoryCount = _biggyMemoryList.Count();
              _biggyMemoryList.Clear();

              BiggyJsonList = new BiggyList<Widget>();

              Assert.True(memoryCount == INSERT_QTY && _biggyMemoryList.Count() == 0 && BiggyJsonList.Count() == INSERT_QTY);
        }
Example #35
0
 public void Initializes_List()
 {
     _biggyMemoryList = new BiggyList <Widget>(_widgetStore, inMemory: true);
     Assert.True(_biggyMemoryList.Count() == INSERT_QTY);
 }
        public void Updates_Item_In_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);
              var updateMe = _biggyMemoryList.FirstOrDefault(w => w.SKU == "001");

              // Update and Save:
              updateMe.Name = "UPDATED";
              _biggyMemoryList.Update(updateMe);

              // Grab from the list:
              var updatedInList = _biggyMemoryList.FirstOrDefault(w => w.SKU == "001");
              var storeWidgets = _widgetStore.Load();
              var originalSotreWidget = storeWidgets.FirstOrDefault(w => w.SKU == "001");

              // Make sure updated in List, but not store:
              Assert.True(updatedInList.Name == "UPDATED" && originalSotreWidget.Name != "UPDATED");
        }
        public void Removes_Range_From_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);

              // Grab a range of items to remove:
              var itemsToRemove = _biggyMemoryList.Where(w => w.Price > 5 && w.Price <= 20);
              int removedQty = itemsToRemove.Count();

              _biggyMemoryList.Remove(itemsToRemove.ToList());

              var storeWidgets = _widgetStore.Load();
              Assert.True(_biggyMemoryList.Count() < storeWidgets.Count());
        }
        public void Removes_Item_From_List_But_Not_Store()
        {
            _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);

              var removeMe = _biggyMemoryList.FirstOrDefault();
              _biggyMemoryList.Remove(removeMe);
              var storeWidgets = _widgetStore.Load();
              Assert.True(_biggyMemoryList.Count() == INSERT_QTY -1 && storeWidgets.Count == INSERT_QTY);
        }
Example #39
0
        public void Removes_Many_Items_From_List_And_Store()
        {
            int INSERT_QTY = 10;

              // Just in case:
              _clients.Clear();
              var addThese = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            addThese.Add(newClient);
              }
              _clients.Add(addThese);

              // Open a new instance, to see if the item was added to the backing store as well:
              var altClientArray = new BiggyList<Client>(_clientStore).ToArray();

              var removeThese = new List<Client>();
              for (int i = 0; i < 5; i++) {
            removeThese.Add(altClientArray[i]);
              }

              _clients.Remove(removeThese);
              // Reload the list:
              _clients = new BiggyList<Client>(_clientStore);
              Assert.True(_clients.Count() == (INSERT_QTY - removeThese.Count()));
        }
Example #40
0
        public void Updates_Item_In_List_And_Store()
        {
            _biggyWidgetList.Clear();
              var updateMe = _biggyWidgetList.Add(new Widget { SKU = "001", Name = "Test widget 1", Price = 2.00M });

              // Update and Save:
              updateMe.Name = "UPDATED";
              _biggyWidgetList.Update(updateMe);

              // Reload the list:
              _biggyWidgetList = new BiggyList<Widget>(_widgets);

              // Grab from the list:
              var updatedInList = _biggyWidgetList.FirstOrDefault(w => w.Name == "UPDATED");

              // Make sure updated in both:
              Assert.True(updatedInList.Name == "UPDATED");
        }
        public void Bulk_Inserts_Documents_With_String_PK()
        {
            int INSERT_QTY = 100;

              var addRange = new List<MonkeyDocument>();
              for (int i = 0; i < INSERT_QTY; i++) {
            addRange.Add(new MonkeyDocument { Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              var inserted = _monkeyDocuments.Add(addRange);

              // Reload, make sure everything was persisted:
              _monkeyDocuments = new BiggyList<MonkeyDocument>(new SQLDocumentStore<MonkeyDocument>(_host));
              Assert.True(_monkeyDocuments.Count() == INSERT_QTY);
        }
Example #42
0
        public void Removes_Range_From_Store()
        {
            _biggyWidgetList.Clear();

              int INSERT_QTY = 100;
              var batch = new List<Widget>();
              for (int i = 0; i < INSERT_QTY; i++) {
            batch.Add(new Widget { SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M + i });
              }
              _biggyWidgetList.Add(batch);
              _biggyWidgetList = new BiggyList<Widget>(_widgets);

              // Grab a range of items to remove:
              var itemsToRemove = _widgets.Load().Where(w => w.Price > 5 && w.Price <= 20);
              int removedQty = itemsToRemove.Count();

              _biggyWidgetList.Remove(itemsToRemove.ToList());

              // Reload again, just to be sure:
              _biggyWidgetList = new BiggyList<Widget>(_widgets);
              Assert.True(removedQty > 0 && removedQty < INSERT_QTY && _biggyWidgetList.Count() == (INSERT_QTY - removedQty));
        }
 public void Initializes_List()
 {
     _biggyMemoryList = new BiggyList<Widget>(_widgetStore, inMemory: true);
       Assert.True(_biggyMemoryList.Count() == INSERT_QTY);
 }
        public void Updates_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
            Email = "*****@*****.**",
            FirstName = "Rob",
            LastName = "Conery"
              };
              _clientDocuments.Add(newCustomer);
              int idToFind = newCustomer.ClientDocumentId;

              // Go find the new record after reloading:
              _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName));
              var updateMe = _clientDocuments.FirstOrDefault(cd => cd.ClientDocumentId == idToFind);
              // Update:
              updateMe.FirstName = "Bill";
              _clientDocuments.Update(updateMe);

              // Go find the updated record after reloading:
              _clientDocuments = new BiggyList<ClientDocument>(new SqlCeDocumentStore<ClientDocument>(_connectionStringName));
              var updated = _clientDocuments.FirstOrDefault(cd => cd.ClientDocumentId == idToFind);
              Assert.True(updated.FirstName == "Bill");
        }