public void Adds_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
                Email     = "*****@*****.**",
                FirstName = "Rob",
                LastName  = "Conery"
            };

            _clientDocuments.Add(newCustomer);
            Assert.Equal(1, _clientDocuments.Count());
        }
Example #2
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);
        }
        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);
        }
        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 #5
0
        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 #6
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);
        }
        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 #9
0
        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 #10
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 #11
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 #12
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 #13
0
        public void Adds_Item_To_List_And_Store()
        {
            // Just in case:
            _clients.Clear();
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _clients.Add(newClient);

            // 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));

            Assert.True(altClientList.Count() > 0);
        }
 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);
 }
        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);
        }