コード例 #1
0
        public void Deletes_all_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #2
0
        public void Updates_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #3
0
        public void Updates_range_of_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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);
        }
コード例 #4
0
        public void Deletes_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #5
0
        public void Deletes_all_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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);
        }
コード例 #6
0
        public void Updates_range_of_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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);
        }
コード例 #7
0
        public void Updates_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #8
0
        public void Deletes_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #9
0
        public void Deletes_all_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #10
0
        public void Deletes_all_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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);
        }
コード例 #11
0
    public void Inserts_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #12
0
    public void Inserts_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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");
    }
コード例 #13
0
    public void Inserts_record_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new PgDocumentStore<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");
    }
コード例 #14
0
    public void Inserts_record_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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);
    }
コード例 #15
0
    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 PgDocumentStore<WidgetDocuments>(_db);
      bool exists = _db.TableExists(widgetstore.TableName);
      Assert.IsTrue(exists);
    }
コード例 #16
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 PgDocumentStore<GuitarDocuments>(_db);
      bool exists = _db.TableExists(guitarstore.TableName);
      Assert.IsTrue(exists);
    }
コード例 #17
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 PgDocumentStore <GuitarDocuments>(_db);
            bool exists      = _db.TableExists(guitarstore.TableName);

            Assert.IsTrue(exists);
        }
コード例 #18
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 PgDocumentStore<CompanyDocuments>(_db);
      bool exists = _db.TableExists(companyStore.TableName);
      Assert.IsTrue(exists);
    }
コード例 #19
0
 public void Inserts_range_of_records_with_string_id() {
   _db.TryDropTable("instrumentdocuments");
   var InstrumentStore = new PgDocumentStore<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);
 }
コード例 #20
0
 public void Inserts_range_of_records_with_string_id() {
   _db.TryDropTable("guitardocuments");
   var guitarstore = new PgDocumentStore<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);
 }
コード例 #21
0
        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 PgDocumentStore <WidgetDocuments>(_db);
            bool exists      = _db.TableExists(widgetstore.TableName);

            Assert.IsTrue(exists);
        }
コード例 #22
0
 public void Inserts_range_of_records_with_int_id() {
   _db.TryDropTable("widgetdocuments");
   var widgetstore = new PgDocumentStore<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);
 }
コード例 #23
0
    public void Updates_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #24
0
    public void Updates_record_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new PgDocumentStore<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);
    }
コード例 #25
0
    public void Updates_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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);
    }
コード例 #26
0
        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");
            _db.TryDropTable("instrumentdocuments");
            var  InstrumentStore = new PgDocumentStore <InstrumentDocuments>(_db);
            bool exists          = _db.TableExists(InstrumentStore.TableName);

            Assert.IsTrue(exists);
        }
コード例 #27
0
    public void Updates_record_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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);
    }
コード例 #28
0
        public void Inserts_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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");
        }
コード例 #29
0
        public void Inserts_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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);
        }
コード例 #30
0
        public void Inserts_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #31
0
        public void Inserts_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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_range_of_records_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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();
      bool IdsGreaterThanZero = companies.All(c => c.Id > 0);

      Assert.IsTrue(companies.Count == qtyToAdd && IdsGreaterThanZero);
    }
コード例 #33
0
        public void Updates_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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);
        }
コード例 #34
0
        public void Updates_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #35
0
        public void Inserts_range_of_records_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #36
0
        public void Inserts_range_of_records_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #37
0
        public void Updates_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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);
        }
コード例 #38
0
        public void Inserts_range_of_records_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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);
        }
コード例 #39
0
        public void Updates_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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);
        }
コード例 #40
0
        public void Inserts_range_of_records_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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();
            bool IdsGreaterThanZero = companies.All(c => c.Id > 0);

            Assert.IsTrue(companies.Count == qtyToAdd && IdsGreaterThanZero);
        }
コード例 #41
0
    public void Updates_range_of_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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);
    }
コード例 #42
0
    public void Updates_range_of_records_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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);
    }
コード例 #43
0
    public void Updates_range_of_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #44
0
        public void Deletes_record_with_serial_id()
        {
            _db.TryDropTable("companydocuments");
            var companyStore = new PgDocumentStore <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);
        }
コード例 #45
0
        public void Deletes_record_with_string_id()
        {
            _db.TryDropTable("instrumentdocuments");
            var InstrumentStore = new PgDocumentStore <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);
        }
コード例 #46
0
        public void Deletes_record_with_string_id()
        {
            _db.TryDropTable("guitardocuments");
            var guitarstore = new PgDocumentStore <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);
        }
コード例 #47
0
        public void Deletes_record_with_int_id()
        {
            _db.TryDropTable("widgetdocuments");
            var widgetstore = new PgDocumentStore <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 PgDocumentStore<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);
    }
コード例 #49
0
    public void Deletes_all_records_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new PgDocumentStore<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);
    }
コード例 #50
0
 public void TryCreateWithAutoStringKey()
 {
     var guitarstore = new PgDocumentStore <ErrorGuitarDocuments>(_db);
 }
コード例 #51
0
 public void TryCreateWithAutoStringKey() {
   var guitarstore = new PgDocumentStore<ErrorGuitarDocuments>(_db);
 }
コード例 #52
0
    public void Updates_range_of_records_with_string_id() {
      _db.TryDropTable("guitardocuments");
      var guitarstore = new PgDocumentStore<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);
    }
コード例 #53
0
    public void Deletes_range_of_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #54
0
    public void Deletes_all_records_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #55
0
    public void Deletes_record_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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);
    }
コード例 #56
0
    public void Deletes_record_with_int_id() {
      _db.TryDropTable("widgetdocuments");
      var widgetstore = new PgDocumentStore<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);
    }
コード例 #57
0
    public void Deletes_range_of_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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);
    }
コード例 #58
0
    public void Deletes_all_records_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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);
    }
コード例 #59
0
    public void Deletes_record_with_string_id() {
      _db.TryDropTable("instrumentdocuments");
      var InstrumentStore = new PgDocumentStore<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);
    }
コード例 #60
0
    public void Deletes_all_records_with_serial_id() {
      _db.TryDropTable("companydocuments");
      var companyStore = new PgDocumentStore<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);
    }