public void Deletes_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var myBatch     = new List <WidgetDocuments>();
            int qtyToAdd    = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new WidgetDocuments {
                    Identifier = i, Category = "Plastic # " + i
                });
            }
            widgetstore.Add(myBatch);

            // Re-load from back-end:
            var companies = widgetstore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Select 5 for deletion:
            int qtyToDelete = 5;
            var deleteThese = new List <WidgetDocuments>();

            for (int i = 0; i < qtyToDelete; i++)
            {
                deleteThese.Add(companies.ElementAt(i));
            }

            // Delete:
            widgetstore.Delete(deleteThese);
            int remaining = widgetstore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
        public void Updates_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var myBatch         = new List <InstrumentDocuments>();
            int qtyToAdd        = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new InstrumentDocuments {
                    Id = "USA #" + i, Category = "String # " + i, Type = "Guitar"
                });
            }
            InstrumentStore.Add(myBatch);

            // Re-load, and update:
            var companies = InstrumentStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).Type = "Banjo " + i;
            }
            InstrumentStore.Update(companies);

            // Reload, and check updated names:
            companies = InstrumentStore.TryLoadData().Where(c => c.Type.StartsWith("Banjo")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Deletes_all_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var myBatch         = new List <InstrumentDocuments>();
            int qtyToAdd        = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new InstrumentDocuments {
                    Id = "USA #" + i, Category = "String # " + i, Type = "Guitar"
                });
            }
            InstrumentStore.Add(myBatch);

            // Re-load from back-end:
            var companies = InstrumentStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            InstrumentStore.DeleteAll();
            int remaining = InstrumentStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
示例#4
0
        public void Updates_range_of_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var myBatch      = new List <CompanyDocuments>();
            int qtyToAdd     = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new CompanyDocuments {
                    Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204"
                });
            }
            companyStore.Add(myBatch);

            // Re-load, and update:
            var companies = companyStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).Name = "Guitar Store # " + i;
            }
            companyStore.Update(companies);

            // Reload, and check updated names:
            companies = companyStore.TryLoadData().Where(c => c.Name.StartsWith("Guitar Store")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
示例#5
0
        public void Updates_range_of_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var myBatch     = new List <GuitarDocuments>();
            int qtyToAdd    = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new GuitarDocuments {
                    Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster"
                });
            }
            guitarstore.Add(myBatch);

            // Re-load, and update:
            var companies = guitarstore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).Model = "Jaguar " + i;
            }
            guitarstore.Update(companies);

            // Reload, and check updated names:
            companies = guitarstore.TryLoadData().Where(c => c.Model.StartsWith("Jaguar")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
示例#6
0
        public void Deletes_all_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var myBatch      = new List <CompanyDocuments>();
            int qtyToAdd     = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new CompanyDocuments {
                    Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204"
                });
            }
            companyStore.Add(myBatch);

            // Re-load from back-end:
            var companies = companyStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            companyStore.DeleteAll();
            int remaining = companyStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
        public void Deletes_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var myBatch         = new List <InstrumentDocuments>();
            int qtyToAdd        = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new InstrumentDocuments {
                    Id = "USA #" + i, Category = "String # " + i, Type = "Guitar"
                });
            }
            InstrumentStore.Add(myBatch);

            // Re-load from back-end:
            var companies = InstrumentStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Select 5 for deletion:
            int qtyToDelete = 5;
            var deleteThese = new List <InstrumentDocuments>();

            for (int i = 0; i < qtyToDelete; i++)
            {
                deleteThese.Add(companies.ElementAt(i));
            }

            // Delete:
            InstrumentStore.Delete(deleteThese);
            int remaining = InstrumentStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
示例#8
0
        public void Deletes_all_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var myBatch     = new List <GuitarDocuments>();
            int qtyToAdd    = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new GuitarDocuments {
                    Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster"
                });
            }
            guitarstore.Add(myBatch);

            // Re-load from back-end:
            var companies = guitarstore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            guitarstore.DeleteAll();
            int remaining = guitarstore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
        public void Updates_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var myBatch     = new List <WidgetDocuments>();
            int qtyToAdd    = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new WidgetDocuments {
                    Identifier = i, Category = "Plastic # " + i
                });
            }
            widgetstore.Add(myBatch);

            // Re-load, and update:
            var companies = widgetstore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).Category = "Silver # " + i;
            }
            widgetstore.Update(companies);

            // Reload, and check updated names:
            companies = widgetstore.TryLoadData().Where(c => c.Category.StartsWith("Silver")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Deletes_all_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var myBatch     = new List <WidgetDocuments>();
            int qtyToAdd    = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new WidgetDocuments {
                    Identifier = i, Category = "Plastic # " + i
                });
            }
            widgetstore.Add(myBatch);

            // Re-load from back-end:
            var companies = widgetstore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            widgetstore.DeleteAll();
            int remaining = widgetstore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
    public void Inserts_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var newInstrument = new InstrumentDocuments { Id = "USA123", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

      var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundInstrument != null && foundInstrument.Id == "USA123");
    }
    public void Inserts_record_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      var newGuitar = new GuitarDocuments { Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom" };
      guitarstore.Add(newGuitar);

      var foundGuitar = guitarstore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundGuitar != null && foundGuitar.Sku == "USA123");
    }
    public void Creates_table_with_string_id() {
      // The Guitar test object has a string field named simply SKU. This will not be matched
      // without an attribute decoration, and horrible plague and pesilence will result.

      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      bool exists = _db.TableExists(guitarstore.TableName);
      Assert.IsTrue(exists);
    }
    public void Inserts_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var newWidget = new WidgetDocuments { Identifier = 100, Category = "Brass" };
      widgetstore.Add(newWidget);

      var foundWidget = widgetstore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundWidget != null && foundWidget.Identifier == 100);
    }
    public void Inserts_record_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
      var newCompany = new CompanyDocuments { Name = "John's Coal Mining Supplies", Address = "16 Company Parkway, Portland, OR 97204" };
      companyStore.Add(newCompany);

      var foundCompany = companyStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundCompany != null && foundCompany.Id == 1);
    }
    public void Creates_table_with_int_id() {
      // The Widget test object has an int field named Identifier. This will not be matched
      // without an attribute decoration, and horrible plague and pesilence will result. Also,
      // the attribute IsAuto property is set to false, so the field will NOT be a serial key.

      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      bool exists = _db.TableExists(widgetstore.TableName);
      Assert.IsTrue(exists);
    }
    public void Creates_table_with_string_id() {
      // The Instrument test object has an int field named simply Id. Without any
      // Attribute decoration, this should result in a table with a serial int PK.

      // NOTE: Gotta go look to see if the field is a serial in or not...
      //var db = new CommandRunner("chinook");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      bool exists = _db.TableExists(InstrumentStore.TableName);
      Assert.IsTrue(exists);
    }
示例#18
0
        public void Creates_table_with_string_id()
        {
            // The Guitar test object has a string field named simply SKU. This will not be matched
            // without an attribute decoration, and horrible plague and pesilence will result.

            _db.TryDropTable("guitardocuments");
            var  guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            bool exists      = _db.TableExists(guitarstore.TableName);

            Assert.IsTrue(exists);
        }
    public void Creates_table_with_serial_id() {
      // The Company test object has an int field named simply "Id". Without any
      // Attribute decoration, this should result in a table with a serial int PK.

      // NOTE: Gotta go look to see if the field is a serial in or not...
      //var db = new CommandRunner("chinook");

      _db.TryDropTable("companydocuments");
      var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
      bool exists = _db.TableExists(companyStore.TableName);
      Assert.IsTrue(exists);
    }
        public void Creates_table_with_string_id()
        {
            // The Instrument test object has an int field named simply Id. Without any
            // Attribute decoration, this should result in a table with a serial int PK.

            // NOTE: Gotta go look to see if the field is a serial in or not...
            //var db = new CommandRunner("chinook");
            var  InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            bool exists          = _db.TableExists(InstrumentStore.TableName);

            Assert.IsTrue(exists);
        }
 public void Inserts_range_of_records_with_string_id() {
   _db.TryDropTable("guitardocuments");
   var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
   var myBatch = new List<GuitarDocuments>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     myBatch.Add(new GuitarDocuments { Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster" });
   }
   guitarstore.Add(myBatch);
   var companies = guitarstore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
        public void Creates_table_with_int_id()
        {
            // The Widget test object has an int field named Identifier. This will not be matched
            // without an attribute decoration, and horrible plague and pesilence will result. Also,
            // the attribute IsAuto property is set to false, so the field will NOT be a serial key.

            _db.TryDropTable("widgetdocuments");
            var  widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            bool exists      = _db.TableExists(widgetstore.TableName);

            Assert.IsTrue(exists);
        }
 public void Inserts_range_of_records_with_serial_id() {
   _db.TryDropTable("companydocuments");
   var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
   var myBatch = new List<CompanyDocuments>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     myBatch.Add(new CompanyDocuments { Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204" });
   }
   companyStore.Add(myBatch);
   var companies = companyStore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
 public void Inserts_range_of_records_with_string_id() {
   _db.TryDropTable("instrumentdocuments");
   var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
   var myBatch = new List<InstrumentDocuments>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" });
   }
   InstrumentStore.Add(myBatch);
   var companies = InstrumentStore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
 public void Inserts_range_of_records_with_int_id() {
   _db.TryDropTable("widgetdocuments");
   var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
   var myBatch = new List<WidgetDocuments>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     myBatch.Add(new WidgetDocuments { Identifier = i, Category = "Plastic # " + i });
   }
   widgetstore.Add(myBatch);
   var companies = widgetstore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
    public void Updates_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var newWidget = new WidgetDocuments { Identifier = 100, Category = "Brass" };
      widgetstore.Add(newWidget);

      // Now go fetch the record again and update:
      string newCategory = "Gold";
      var foundWidget = widgetstore.TryLoadData().FirstOrDefault();
      foundWidget.Category = newCategory;
      widgetstore.Update(foundWidget);
      Assert.IsTrue(foundWidget != null && foundWidget.Category == newCategory);
    }
    public void Updates_record_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
      var newCompany = new CompanyDocuments { Name = "John's Coal Mining Supplies", Address = "16 Company Parkway, Portland, OR 97204" };
      companyStore.Add(newCompany);

      // Now go fetch the record again and update:
      string newName = "John's Guitars";
      var foundCompany = companyStore.TryLoadData().FirstOrDefault();
      foundCompany.Name = newName;
      companyStore.Update(foundCompany);
      Assert.IsTrue(foundCompany != null && foundCompany.Name == newName);
    }
    public void Updates_record_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      var newGuitar = new GuitarDocuments { Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom" };
      guitarstore.Add(newGuitar);

      // Now go fetch the record again and update:
      string newModel = "Explorer";
      var foundGuitar = guitarstore.TryLoadData().FirstOrDefault();
      foundGuitar.Model = newModel;
      guitarstore.Update(foundGuitar);
      Assert.IsTrue(foundGuitar != null && foundGuitar.Model == newModel);
    }
    public void Updates_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var newInstrument = new InstrumentDocuments { Id = "USA123", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

      // Now go fetch the record again and update:
      string newType = "Banjo";
      var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault();
      foundInstrument.Type = newType;
      InstrumentStore.Update(foundInstrument);
      Assert.IsTrue(foundInstrument != null && foundInstrument.Type == newType);
    }
示例#30
0
        public void Creates_table_with_serial_id()
        {
            // The Company test object has an int field named simply "Id". Without any
            // Attribute decoration, this should result in a table with a serial int PK.

            // NOTE: Gotta go look to see if the field is a serial in or not...
            //var db = new CommandRunner("chinook");

            _db.TryDropTable("companydocuments");
            var  companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            bool exists       = _db.TableExists(companyStore.TableName);

            Assert.IsTrue(exists);
        }
        public void Inserts_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var newInstrument   = new InstrumentDocuments {
                Id = "USA123", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

            var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundInstrument != null && foundInstrument.Id == "USA123");
        }
示例#32
0
        public void Inserts_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var newGuitar   = new GuitarDocuments {
                Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom"
            };

            guitarstore.Add(newGuitar);

            var foundGuitar = guitarstore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundGuitar != null && foundGuitar.Sku == "USA123");
        }
        public void Inserts_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var newWidget   = new WidgetDocuments {
                Identifier = 100, Category = "Brass"
            };

            widgetstore.Add(newWidget);

            var foundWidget = widgetstore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundWidget != null && foundWidget.Identifier == 100);
        }
示例#34
0
        public void Inserts_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var newCompany   = new CompanyDocuments {
                Name = "John's Coal Mining Supplies", Address = "16 Company Parkway, Portland, OR 97204"
            };

            companyStore.Add(newCompany);

            var foundCompany = companyStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundCompany != null && foundCompany.Id == 1);
        }
        public void Inserts_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var myBatch     = new List <WidgetDocuments>();
            int qtyToAdd    = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new WidgetDocuments {
                    Identifier = i, Category = "Plastic # " + i
                });
            }
            widgetstore.Add(myBatch);
            var companies = widgetstore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Updates_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var newWidget   = new WidgetDocuments {
                Identifier = 100, Category = "Brass"
            };

            widgetstore.Add(newWidget);

            // Now go fetch the record again and update:
            string newCategory = "Gold";
            var    foundWidget = widgetstore.TryLoadData().FirstOrDefault();

            foundWidget.Category = newCategory;
            widgetstore.Update(foundWidget);
            Assert.IsTrue(foundWidget != null && foundWidget.Category == newCategory);
        }
示例#37
0
        public void Inserts_range_of_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var myBatch     = new List <GuitarDocuments>();
            int qtyToAdd    = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new GuitarDocuments {
                    Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster"
                });
            }
            guitarstore.Add(myBatch);
            var companies = guitarstore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
示例#38
0
        public void Updates_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var newGuitar   = new GuitarDocuments {
                Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom"
            };

            guitarstore.Add(newGuitar);

            // Now go fetch the record again and update:
            string newModel    = "Explorer";
            var    foundGuitar = guitarstore.TryLoadData().FirstOrDefault();

            foundGuitar.Model = newModel;
            guitarstore.Update(foundGuitar);
            Assert.IsTrue(foundGuitar != null && foundGuitar.Model == newModel);
        }
示例#39
0
        public void Inserts_range_of_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var myBatch      = new List <CompanyDocuments>();
            int qtyToAdd     = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new CompanyDocuments {
                    Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204"
                });
            }
            companyStore.Add(myBatch);
            var companies = companyStore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
示例#40
0
        public void Updates_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var newCompany   = new CompanyDocuments {
                Name = "John's Coal Mining Supplies", Address = "16 Company Parkway, Portland, OR 97204"
            };

            companyStore.Add(newCompany);

            // Now go fetch the record again and update:
            string newName      = "John's Guitars";
            var    foundCompany = companyStore.TryLoadData().FirstOrDefault();

            foundCompany.Name = newName;
            companyStore.Update(foundCompany);
            Assert.IsTrue(foundCompany != null && foundCompany.Name == newName);
        }
        public void Inserts_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var myBatch         = new List <InstrumentDocuments>();
            int qtyToAdd        = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new InstrumentDocuments {
                    Id = "USA #" + i, Category = "String # " + i, Type = "Guitar"
                });
            }
            InstrumentStore.Add(myBatch);
            var companies = InstrumentStore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Updates_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var newInstrument   = new InstrumentDocuments {
                Id = "USA123", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

            // Now go fetch the record again and update:
            string newType         = "Banjo";
            var    foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault();

            foundInstrument.Type = newType;
            InstrumentStore.Update(foundInstrument);
            Assert.IsTrue(foundInstrument != null && foundInstrument.Type == newType);
        }
    public void Updates_range_of_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var myBatch = new List<WidgetDocuments>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new WidgetDocuments { Identifier = i, Category = "Plastic # " + i });
      }
      widgetstore.Add(myBatch);

      // Re-load, and update:
      var companies = widgetstore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).Category = "Silver # " + i;
      }
      widgetstore.Update(companies);

      // Reload, and check updated names:
      companies = widgetstore.TryLoadData().Where(c => c.Category.StartsWith("Silver")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
    public void Updates_range_of_records_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
      var myBatch = new List<CompanyDocuments>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new CompanyDocuments { Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204" });
      }
      companyStore.Add(myBatch);

      // Re-load, and update:
      var companies = companyStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).Name = "Guitar Store # " + i;
      }
      companyStore.Update(companies);

      // Reload, and check updated names:
      companies = companyStore.TryLoadData().Where(c => c.Name.StartsWith("Guitar Store")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
    public void Updates_range_of_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var myBatch = new List<InstrumentDocuments>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" });
      }
      InstrumentStore.Add(myBatch);

      // Re-load, and update:
      var companies = InstrumentStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).Type = "Banjo " + i;
      }
      InstrumentStore.Update(companies);

      // Reload, and check updated names:
      companies = InstrumentStore.TryLoadData().Where(c => c.Type.StartsWith("Banjo")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
示例#46
0
        public void Deletes_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new SqliteDocumentStore <CompanyDocuments>(_db);
            var newCompany   = new CompanyDocuments {
                Name = "John's Coal Mining Supplies", Address = "16 Company Parkway, Portland, OR 97204"
            };

            companyStore.Add(newCompany);

            // Load from back-end:
            var companies = companyStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundCompany = companies.FirstOrDefault();

            companyStore.Delete(foundCompany);

            int remaining = companyStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
        public void Deletes_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new SqliteDocumentStore <WidgetDocuments>(_db);
            var newWidget   = new WidgetDocuments {
                Identifier = 100, Category = "Brass"
            };

            widgetstore.Add(newWidget);

            // Load from back-end:
            var companies = widgetstore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundWidget = companies.FirstOrDefault();

            widgetstore.Delete(foundWidget);

            int remaining = widgetstore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
示例#48
0
        public void Deletes_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new SqliteDocumentStore <GuitarDocuments>(_db);
            var newGuitar   = new GuitarDocuments {
                Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom"
            };

            guitarstore.Add(newGuitar);

            // Load from back-end:
            var companies = guitarstore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundGuitar = companies.FirstOrDefault();

            guitarstore.Delete(foundGuitar);

            int remaining = guitarstore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
        public void Deletes_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new SqliteDocumentStore <InstrumentDocuments>(_db);
            var newInstrument   = new InstrumentDocuments {
                Id = "USA123", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

            // Load from back-end:
            var companies = InstrumentStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundInstrument = companies.FirstOrDefault();

            InstrumentStore.Delete(foundInstrument);

            int remaining = InstrumentStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
    public void Deletes_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var newInstrument = new InstrumentDocuments { Id = "USA123", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

      // Load from back-end:
      var companies = InstrumentStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      var foundInstrument = companies.FirstOrDefault();
      InstrumentStore.Delete(foundInstrument);

      int remaining = InstrumentStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Deletes_range_of_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var myBatch = new List<InstrumentDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" });
      }
      InstrumentStore.Add(myBatch);

      // Re-load from back-end:
      var companies = InstrumentStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Select 5 for deletion:
      int qtyToDelete = 5;
      var deleteThese = new List<InstrumentDocuments>();
      for (int i = 0; i < qtyToDelete; i++) {
        deleteThese.Add(companies.ElementAt(i));
      }

      // Delete:
      InstrumentStore.Delete(deleteThese);
      int remaining = InstrumentStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Deletes_all_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new SqliteDocumentStore<InstrumentDocuments>(_db);
      var myBatch = new List<InstrumentDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new InstrumentDocuments { Id = "USA #" + i, Category = "String # " + i, Type = "Guitar" });
      }
      InstrumentStore.Add(myBatch);

      // Re-load from back-end:
      var companies = InstrumentStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      InstrumentStore.DeleteAll();
      int remaining = InstrumentStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
    public void Deletes_all_records_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      var myBatch = new List<GuitarDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new GuitarDocuments { Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster" });
      }
      guitarstore.Add(myBatch);

      // Re-load from back-end:
      var companies = guitarstore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      guitarstore.DeleteAll();
      int remaining = guitarstore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
    public void Deletes_all_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var myBatch = new List<WidgetDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new WidgetDocuments { Identifier = i, Category = "Plastic # " + i });
      }
      widgetstore.Add(myBatch);

      // Re-load from back-end:
      var companies = widgetstore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      widgetstore.DeleteAll();
      int remaining = widgetstore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
    public void Updates_range_of_records_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      var myBatch = new List<GuitarDocuments>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new GuitarDocuments { Sku = "USA # " + i, Make = "Fender", Model = "Stratocaster" });
      }
      guitarstore.Add(myBatch);

      // Re-load, and update:
      var companies = guitarstore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).Model = "Jaguar " + i;
      }
      guitarstore.Update(companies);

      // Reload, and check updated names:
      companies = guitarstore.TryLoadData().Where(c => c.Model.StartsWith("Jaguar")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
    public void Deletes_record_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new SqliteDocumentStore<GuitarDocuments>(_db);
      var newGuitar = new GuitarDocuments { Sku = "USA123", Make = "Gibson", Model = "Les Paul Custom" };
      guitarstore.Add(newGuitar);

      // Load from back-end:
      var companies = guitarstore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      var foundGuitar = companies.FirstOrDefault();
      guitarstore.Delete(foundGuitar);

      int remaining = guitarstore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Deletes_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var newWidget = new WidgetDocuments { Identifier = 100, Category = "Brass" };
      widgetstore.Add(newWidget);

      // Load from back-end:
      var companies = widgetstore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      var foundWidget = companies.FirstOrDefault();
      widgetstore.Delete(foundWidget);

      int remaining = widgetstore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
 public void TryCreateWithAutoStringKey() {
   var guitarstore = new SqliteDocumentStore<ErrorGuitarDocuments>(_db);
 }
    public void Deletes_range_of_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new SqliteDocumentStore<WidgetDocuments>(_db);
      var myBatch = new List<WidgetDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new WidgetDocuments { Identifier = i, Category = "Plastic # " + i });
      }
      widgetstore.Add(myBatch);

      // Re-load from back-end:
      var companies = widgetstore.TryLoadData();
      int qtyAdded = companies.Count;

      // Select 5 for deletion:
      int qtyToDelete = 5;
      var deleteThese = new List<WidgetDocuments>();
      for (int i = 0; i < qtyToDelete; i++) {
        deleteThese.Add(companies.ElementAt(i));
      }

      // Delete:
      widgetstore.Delete(deleteThese);
      int remaining = widgetstore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Deletes_all_records_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new SqliteDocumentStore<CompanyDocuments>(_db);
      var myBatch = new List<CompanyDocuments>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new CompanyDocuments { Name = "Company Store #" + i, Address = i + " Company Parkway, Portland, OR 97204" });
      }
      companyStore.Add(myBatch);

      // Re-load from back-end:
      var companies = companyStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      companyStore.DeleteAll();
      int remaining = companyStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }