コード例 #1
0
        public void Delete_Customer_In_Customers_Collection(string name, string dbName)
        {
            this.Destroy($@"E:\Git\c-sharp-libs\tests\dbs\{dbName}.db");
            var localDb = new LocalDb(dbName, @"E:\Git\c-sharp-libs\tests\dbs");
            var col     = localDb.GetCollection <Customer>(name);

            col.EnsureIndex(x => x.Name, true);

            var customer = new Customer
            {
                Name     = "John Doe",
                Phones   = new string[] { "8000-0000", "9000-0000" },
                Age      = 39,
                IsActive = true
            };

            localDb.InsertDocument <Customer>(col, customer);
            var results = col.Find(x => x.Name == customer.Name);

            Assert.AreEqual(results.ToArray().Count(), 1);

            var cust = (Customer)results.ToArray()[0];

            localDb.DeleteDocument <Customer>(col, cust._id);
            var newResults = col.Find(x => x.Name == customer.Name);

            Assert.AreEqual(newResults.ToArray().Count(), 0);
        }