Exemplo n.º 1
0
    public void jsonStore_Inserts_record_with_string_id() {
      var InstrumentStore = new JsonStore<InstrumentDocuments>();
      var newInstrument = new InstrumentDocuments { Id = "USA123", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

      var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA123");
      Assert.IsTrue(foundInstrument != null && foundInstrument.Id == "USA123");
    }
    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");
    }
Exemplo n.º 3
0
    public void jsonStore_Updates_record_with_string_id() {
      var InstrumentStore = new JsonStore<InstrumentDocuments>();
      var newInstrument = new InstrumentDocuments { Id = "USA456", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

      // Now go fetch the record again and update:
      string newType = "Banjo";
      var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA456");
      foundInstrument.Type = newType;
      InstrumentStore.Update(foundInstrument);
      Assert.IsTrue(foundInstrument != null && foundInstrument.Type == newType);
    }
    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);
    }
Exemplo n.º 5
0
        public void jsonStore_Inserts_record_with_string_id()
        {
            var InstrumentStore = new JsonStore <InstrumentDocuments>();
            var newInstrument   = new InstrumentDocuments {
                Id = "USA123", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

            var foundInstrument = InstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA123");

            Assert.IsTrue(foundInstrument != null && foundInstrument.Id == "USA123");
        }
        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");
        }
Exemplo n.º 7
0
        public void AzureStore_Inserts_record_with_string_id()
        {
            // Given
            var instrumentStore = GetAzureStore();
            InstrumentDocuments newInstrument = GetSingleItem();

            // When
            instrumentStore.Add(newInstrument);

            // Then
            var newVersionOfinstrumentStore = GetAzureStore();
            var foundInstrument             = newVersionOfinstrumentStore.TryLoadData().FirstOrDefault(i => i.Id == "USA123");

            Assert.IsNotNull(foundInstrument);
        }
Exemplo n.º 8
0
    public void jsonStore_Deletes_record_with_string_id() {
      var InstrumentStore = new JsonStore<InstrumentDocuments>();
      var newInstrument = new InstrumentDocuments { Id = "USA789", Category = "String", Type = "Guitar" };
      InstrumentStore.Add(newInstrument);

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

      // Delete:
      var foundInstrument = companies.FirstOrDefault(i => i.Id == "USA789");
      InstrumentStore.Delete(foundInstrument);

      int remaining = InstrumentStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
Exemplo n.º 9
0
        public void jsonStore_Updates_record_with_string_id()
        {
            var InstrumentStore = new JsonStore <InstrumentDocuments>();
            var newInstrument   = new InstrumentDocuments {
                Id = "USA456", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

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

            foundInstrument.Type = newType;
            InstrumentStore.Update(foundInstrument);
            Assert.IsTrue(foundInstrument != null && foundInstrument.Type == newType);
        }
        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 InMemory_Compare_The_Same_Instance()
        {
            // Given
            var firstItem = new InstrumentDocuments
            {
                Id = "1",
                Category = "Cat1",
                Type = "Alpha",
            };
            var locator = new ItemsAreEqualsByReference<InstrumentDocuments>(firstItem);
            var secondItem = firstItem;

            // When
            var result = locator.IsMatch(secondItem);

            // Then
            Assert.IsTrue(result);
        }
Exemplo n.º 12
0
        public void InMemory_Compare_The_Same_Instance()
        {
            // Given
            var firstItem = new InstrumentDocuments
            {
                Id       = "1",
                Category = "Cat1",
                Type     = "Alpha",
            };
            var locator    = new ItemsAreEqualsByReference <InstrumentDocuments>(firstItem);
            var secondItem = firstItem;

            // When
            var result = locator.IsMatch(secondItem);

            // Then
            Assert.IsTrue(result);
        }
Exemplo n.º 13
0
        public void jsonStore_Deletes_record_with_string_id()
        {
            var InstrumentStore = new JsonStore <InstrumentDocuments>();
            var newInstrument   = new InstrumentDocuments {
                Id = "USA789", Category = "String", Type = "Guitar"
            };

            InstrumentStore.Add(newInstrument);

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

            // Delete:
            var foundInstrument = companies.FirstOrDefault(i => i.Id == "USA789");

            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);
        }
Exemplo n.º 15
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);
    }