Esempio n. 1
0
 public void TestPutManyRemoved()
 {
     using (var connection = CreateConnection())
         using (var db = new IsabelDb(connection, null, NoCustomTypes, false, false))
         {
             var collection = db.GetOrCreateMultiValueDictionary <int, string>("Blessthefall");
             collection.Put(1, "Wishful Sinking");
             db.Remove(collection);
             new Action(() => collection.PutMany(2, new[] { "Find Yourself", "Sakura Blues" }))
             .Should().Throw <InvalidOperationException>()
             .WithMessage("This collection (\"Blessthefall\") has been removed from the database and may no longer be used");
         }
 }
Esempio n. 2
0
        public void TestRemoveAllReadOnlyDatabase()
        {
            using (var connection = CreateConnection())
            {
                using (var db = new IsabelDb(connection, null, NoCustomTypes, false, false))
                {
                    var collection = db.GetOrCreateMultiValueDictionary <int, string>("Stuff");
                    collection.Put(1, "One");
                    collection.Put(1, "Two");
                }

                using (var db = new IsabelDb(connection, null, NoCustomTypes, false, isReadOnly: true))
                {
                    var collection = db.GetOrCreateMultiValueDictionary <int, string>("Stuff");
                    collection.GetAllValues().Should().Equal("One", "Two");

                    new Action(() => collection.RemoveAll(1))
                    .Should().Throw <InvalidOperationException>()
                    .WithMessage("The database has been opened read-only and therefore may not be modified");

                    collection.GetAllValues().Should().Equal("One", "Two");
                }
            }
        }