public void CustomIDTest()
        {
            var x  = new MongoRepository <CustomIDEntity>();
            var xm = new MongoRepositoryManager <CustomIDEntity>();

            x.Add(new CustomIDEntity()
            {
                Id = "aaa"
            });

            Assert.IsTrue(xm.Exists);
            Assert.IsInstanceOfType(x.GetById("aaa"), typeof(CustomIDEntity));

            Assert.AreEqual("aaa", x.GetById("aaa").Id);

            x.Delete("aaa");
            Assert.AreEqual(0, x.Count());

            var y  = new MongoRepository <CustomIDEntityCustomCollection>();
            var ym = new MongoRepositoryManager <CustomIDEntityCustomCollection>();

            y.Add(new CustomIDEntityCustomCollection()
            {
                Id = "xyz"
            });

            Assert.IsTrue(ym.Exists);
            Assert.AreEqual(ym.Name, "MyTestCollection");
            Assert.AreEqual(y.CollectionName, "MyTestCollection");
            Assert.IsInstanceOfType(y.GetById("xyz"), typeof(CustomIDEntityCustomCollection));

            y.Delete("xyz");
            Assert.AreEqual(0, y.Count());
        }
Esempio n. 2
0
        public void AddAndUpdateTest()
        {
            var customerRepository = new MongoRepository <Customer>();
            var customerManager    = new MongoRepositoryManager <Customer>();

            //_customerManager.Exists.ShouldBeFalse();

            var customer = new Customer();

            customer.FirstName   = "Bob";
            customer.LastName    = "Dillon";
            customer.Phone       = "0900999899";
            customer.Email       = new CustomerEmail("*****@*****.**");
            customer.HomeAddress = new Address
            {
                Address1 = "North kingdom 15 west",
                Address2 = "1 north way",
                City     = "George Town",
                Country  = "Alaska",
                PostCode = "40990"
            };

            customerRepository.Add(customer);

            customerManager.Exists.ShouldBeTrue();
            customer.Id.ShouldNotBeNullOrWhiteSpace();

            // fetch it back
            var alreadyAddedCustomer = customerRepository.Where(c => c.FirstName == "Bob").Single();

            alreadyAddedCustomer.ShouldNotBeNull();
            customer.FirstName.ShouldBe(alreadyAddedCustomer.FirstName);
            customer.HomeAddress.Address1.ShouldBe(alreadyAddedCustomer.HomeAddress.Address1);

            alreadyAddedCustomer.Phone = "10110111";
            alreadyAddedCustomer.Email = new CustomerEmail("*****@*****.**");

            customerRepository.Update(alreadyAddedCustomer);

            // fetch by id now
            var updatedCustomer = customerRepository.GetById(customer.Id);

            updatedCustomer.ShouldNotBeNull();
            alreadyAddedCustomer.Phone.ShouldBe(updatedCustomer.Phone);
            alreadyAddedCustomer.Email.Value.ShouldBe(updatedCustomer.Email.Value);
            customerRepository.Exists(c => c.HomeAddress.Country == "Alaska").ShouldBeTrue();

            customerRepository.Delete(updatedCustomer);

            var exists = customerRepository.GetById(updatedCustomer.Id);

            exists.ShouldBeNull();

            customerRepository.DeleteAll();
        }
        public void AutoCreatedCollectionIsNotCapped()
        {
            var products       = CreateRandomRepository <Product>();
            var productManager = new MongoRepositoryManager <Product>(MongoUrl, products.CollectionName);

            products.Add(new Product()
            {
                Name = "Product 10", Description = "Product 10", Price = 10
            });
            Assert.False(productManager.IsCapped());
        }
        public void Exists()
        {
            var products       = CreateRandomRepository <Product>();
            var productManager = new MongoRepositoryManager <Product>(MongoUrl, products.CollectionName);

            products.Add(new Product()
            {
                Name = "Product 10", Description = "Product 10", Price = 10
            });
            Assert.True(productManager.Exists());
        }
Esempio n. 5
0
        public void OneTimeTearDown()
        {
            // Drop the database
            _collectionManager.DropDatabase();

            // Clean up memory; send to garbage collector
            _mapper            = null;
            _config            = null;
            _connectionString  = null;
            _collectionManager = null;
        }
        public void AddAndUpdateTest()
        {
            IRepository <Customer>        _customerRepo = new MongoRepository <Customer>();
            IRepositoryManager <Customer> _customerMan  = new MongoRepositoryManager <Customer>();

            Assert.IsFalse(_customerMan.Exists);

            var customer = new Customer();

            customer.FirstName   = "Bob";
            customer.LastName    = "Dillon";
            customer.Phone       = "0900999899";
            customer.Email       = "*****@*****.**";
            customer.HomeAddress = new Address
            {
                Address1 = "North kingdom 15 west",
                Address2 = "1 north way",
                PostCode = "40990",
                City     = "George Town",
                Country  = "Alaska"
            };

            _customerRepo.Add(customer);

            Assert.IsTrue(_customerMan.Exists);

            Assert.IsNotNull(customer.Id);

            // fetch it back
            var alreadyAddedCustomer = _customerRepo.Where(c => c.FirstName == "Bob").Single();

            Assert.IsNotNull(alreadyAddedCustomer);
            Assert.AreEqual(customer.FirstName, alreadyAddedCustomer.FirstName);
            Assert.AreEqual(customer.HomeAddress.Address1, alreadyAddedCustomer.HomeAddress.Address1);

            alreadyAddedCustomer.Phone = "10110111";
            alreadyAddedCustomer.Email = "*****@*****.**";

            _customerRepo.Update(alreadyAddedCustomer);

            // fetch by id now
            var updatedCustomer = _customerRepo.GetById(customer.Id);

            Assert.IsNotNull(updatedCustomer);
            Assert.AreEqual(alreadyAddedCustomer.Phone, updatedCustomer.Phone);
            Assert.AreEqual(alreadyAddedCustomer.Email, updatedCustomer.Email);

            Assert.IsTrue(_customerRepo.Exists(c => c.HomeAddress.Country == "Alaska"));
        }
        public async void DropAsync()
        {
            var products       = CreateRandomRepository <Product>();
            var productManager = new MongoRepositoryManager <Product>(MongoUrl, products.CollectionName);

            await products.AddAsync(new Product()
            {
                Name = "Product 10", Description = "Product 10", Price = 10
            });

            Assert.True(await productManager.ExistsAsync());
            await productManager.DropAsync();

            Assert.False(await productManager.ExistsAsync());
        }
        public void AddAndUpdateTest()
        {
            IRepository<Customer> _customerRepo = new MongoRepository<Customer>();
            IRepositoryManager<Customer> _customerMan = new MongoRepositoryManager<Customer>();

            Assert.IsFalse(_customerMan.Exists);

            var customer = new Customer();
            customer.FirstName = "Bob";
            customer.LastName = "Dillon";
            customer.Phone = "0900999899";
            customer.Email = "*****@*****.**";
            customer.HomeAddress = new Address
            {
                Address1 = "North kingdom 15 west",
                Address2 = "1 north way",
                PostCode = "40990",
                City = "George Town",
                Country = "Alaska"
            };

            _customerRepo.Add(customer);

            Assert.IsTrue(_customerMan.Exists);

            Assert.IsNotNull(customer.Id);

            // fetch it back
            var alreadyAddedCustomer = _customerRepo.Where(c => c.FirstName == "Bob").Single();

            Assert.IsNotNull(alreadyAddedCustomer);
            Assert.AreEqual(customer.FirstName, alreadyAddedCustomer.FirstName);
            Assert.AreEqual(customer.HomeAddress.Address1, alreadyAddedCustomer.HomeAddress.Address1);

            alreadyAddedCustomer.Phone = "10110111";
            alreadyAddedCustomer.Email = "*****@*****.**";

            _customerRepo.Update(alreadyAddedCustomer);

            // fetch by id now
            var updatedCustomer = _customerRepo.GetById(customer.Id);

            Assert.IsNotNull(updatedCustomer);
            Assert.AreEqual(alreadyAddedCustomer.Phone, updatedCustomer.Phone);
            Assert.AreEqual(alreadyAddedCustomer.Email, updatedCustomer.Email);

            Assert.IsTrue(_customerRepo.Exists(c => c.HomeAddress.Country == "Alaska"));
        }
        public void OverrideCollectionName()
        {
            IRepository <Customer> _customerRepo = new MongoRepository <Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");

            _customerRepo.Add(new Customer()
            {
                FirstName = "Test"
            });
            Assert.IsTrue(_customerRepo.Single().FirstName.Equals("Test"));
            Assert.AreEqual("TestCustomers123", _customerRepo.Collection.CollectionNamespace.CollectionName);
            Assert.AreEqual("TestCustomers123", ((MongoRepository <Customer>)_customerRepo).CollectionName);

            IRepositoryManager <Customer> _curstomerRepoManager = new MongoRepositoryManager <Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");

            Assert.AreEqual("TestCustomers123", _curstomerRepoManager.Name);
        }
Esempio n. 10
0
        public void DuplicateIndexIsIdempotent()
        {
            var manager            = new MongoRepositoryManager <Customer>();
            var customerRepository = new MongoRepository <Customer>();

            // customerRepository.Add(new Customer{FirstName = "Joe", LastName = "Smith 1"});
            // var index1 = manager.EnsureIndex(o => o.Email.Value, true, true, true);
            // var index2 = manager.EnsureIndex(o => o.Email.Value, true, true, true);
            // Expression<Func<Customer, string>> exp1 = o => o.Logins.Value;
            // Expression<Func<Customer, string>> exp1 = o => o.Email.Value;
            // manager.EnsureIndex( new [] { o => o.Email.Value }, true, true, true);
            // manager.EnsureIndex(new[] {  "Logins.LoginProvider", "Logins.ProviderKey" }, true, true, true);

            // manager.DropIndex(index1);
            // manager.DropIndex(index2);
        }
Esempio n. 11
0
        public static void Register()
        {
            var stories = new MongoRepositoryManager<Story>();
            stories.EnsureIndex("Slug");
            stories.EnsureIndex("Genre");
            stories.EnsureIndex("GroupId");
            stories.EnsureIndex("CreatedDate");
            stories.EnsureIndex("CreatorId");

            var groups = new MongoRepositoryManager<Group>();
            groups.EnsureIndex("Slug");
            groups.EnsureIndex("CreatedDate");
            groups.EnsureIndex("CreatorId");

            var users = new MongoRepositoryManager<User>();
            users.EnsureIndex("DisplayName");
        }
Esempio n. 12
0
        public void OneTimeSetUp()
        {
            var config = new MapperConfiguration(cfg => {
                cfg.AddProfile <MongoMappingProfile>();
            });

            _mapper = config.CreateMapper();

            var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var builder         = new ConfigurationBuilder()
                                  .AddJsonFile($"appsettings.json", true, true)
                                  .AddJsonFile($"appsettings.{environmentName}.json", true, true)
                                  .AddEnvironmentVariables();

            _config = builder.Build();

            _connectionString  = _config.GetConnectionString("NoteTakingTest");
            _collectionManager = new MongoRepositoryManager <MongoCategory, Guid>(_connectionString, "Categories");
            _collectionManager.DropDatabase();
        }
        public async void IsCappedAsync()
        {
            var products = CreateRandomRepository <Product>();
            var mongoUrl = new MongoUrl(MongoUrl);
            var client   = new MongoClient(mongoUrl);
            var options  = new CreateCollectionOptions()
            {
                Capped = true, MaxSize = 1024768, MaxDocuments = 10000
            };
            var database = client.GetDatabase(mongoUrl.DatabaseName);
            await database.CreateCollectionAsync(products.CollectionName, options);

            await products.AddAsync(new Product()
            {
                Name = "Product 10", Description = "Product 10", Price = 10
            });

            var productManager = new MongoRepositoryManager <Product>(MongoUrl, products.CollectionName);

            Assert.True(await productManager.IsCappedAsync());
        }
Esempio n. 14
0
        public void CustomIDTest()
        {
            var customIdRepository = new MongoRepository <CustomIDEntity>();
            var customIdManager    = new MongoRepositoryManager <CustomIDEntity>();

            customIdRepository.DeleteAll();

            customIdRepository.Add(new CustomIDEntity()
            {
                Id = "aaa"
            });

            customIdManager.Exists.ShouldBeTrue();
            customIdRepository.GetById("aaa").ShouldBeOfType(typeof(CustomIDEntity));
            customIdRepository.GetById("aaa").Id.ShouldBe("aaa");

            customIdRepository.Delete("aaa");
            customIdRepository.Count().ShouldBe(0);

            var y  = new MongoRepository <CustomIDEntityCustomCollection>();
            var ym = new MongoRepositoryManager <CustomIDEntityCustomCollection>();

            y.DeleteAll();

            y.Add(new CustomIDEntityCustomCollection()
            {
                Id = "xyz"
            });

            ym.Exists.ShouldBeTrue();
            ym.Name.ShouldBe("MyTestCollection");
            y.CollectionName.ShouldBe("MyTestCollection");
            y.GetById("xyz").ShouldBeOfType(typeof(CustomIDEntityCustomCollection));

            y.Delete("xyz");
            y.Count().ShouldBe(0);

            customIdRepository.DeleteAll();
        }
        public void OverrideCollectionName()
        {
            IRepository<Customer> _customerRepo = new MongoRepository<Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");
            _customerRepo.Add(new Customer() { FirstName = "Test" });
            Assert.IsTrue(_customerRepo.Single().FirstName.Equals("Test"));
            Assert.AreEqual("TestCustomers123", _customerRepo.Collection.Name);
            Assert.AreEqual("TestCustomers123", ((MongoRepository<Customer>)_customerRepo).CollectionName);

            IRepositoryManager<Customer> _curstomerRepoManager = new MongoRepositoryManager<Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");
            Assert.AreEqual("TestCustomers123", _curstomerRepoManager.Name);
        }
        public void CustomIDTest()
        {
            var x = new MongoRepository<CustomIDEntity>();
            var xm = new MongoRepositoryManager<CustomIDEntity>();

            x.Add(new CustomIDEntity() { Id = "aaa" });

            Assert.IsTrue(xm.Exists);
            Assert.IsInstanceOfType(x.GetById("aaa"), typeof(CustomIDEntity));

            Assert.AreEqual("aaa", x.GetById("aaa").Id);

            x.Delete("aaa");
            Assert.AreEqual(0, x.Count());

            var y = new MongoRepository<CustomIDEntityCustomCollection>();
            var ym = new MongoRepositoryManager<CustomIDEntityCustomCollection>();

            y.Add(new CustomIDEntityCustomCollection() { Id = "xyz" });

            Assert.IsTrue(ym.Exists);
            Assert.AreEqual(ym.Name, "MyTestCollection");
            Assert.AreEqual(y.CollectionName, "MyTestCollection");
            Assert.IsInstanceOfType(y.GetById("xyz"), typeof(CustomIDEntityCustomCollection));

            y.Delete("xyz");
            Assert.AreEqual(0, y.Count());
        }
        public void CollectionNamesTest()
        {
            var a = new MongoRepository<Animal>();
            var am = new MongoRepositoryManager<Animal>();
            var va = new Dog();
            Assert.IsFalse(am.Exists);
            a.Update(va);
            Assert.IsTrue(am.Exists);
            Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog));
            Assert.AreEqual(am.Name, "AnimalsTest");
            Assert.AreEqual(a.CollectionName, "AnimalsTest");

            var cl = new MongoRepository<CatLike>();
            var clm = new MongoRepositoryManager<CatLike>();
            var vcl = new Lion();
            Assert.IsFalse(clm.Exists);
            cl.Update(vcl);
            Assert.IsTrue(clm.Exists);
            Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion));
            Assert.AreEqual(clm.Name, "Catlikes");
            Assert.AreEqual(cl.CollectionName, "Catlikes");

            var b = new MongoRepository<Bird>();
            var bm = new MongoRepositoryManager<Bird>();
            var vb = new Bird();
            Assert.IsFalse(bm.Exists);
            b.Update(vb);
            Assert.IsTrue(bm.Exists);
            Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird));
            Assert.AreEqual(bm.Name, "Birds");
            Assert.AreEqual(b.CollectionName, "Birds");

            var l = new MongoRepository<Lion>();
            var lm = new MongoRepositoryManager<Lion>();
            var vl = new Lion();
            //Assert.IsFalse(lm.Exists);   //Should already exist (created by cl)
            l.Update(vl);
            Assert.IsTrue(lm.Exists);
            Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion));
            Assert.AreEqual(lm.Name, "Catlikes");
            Assert.AreEqual(l.CollectionName, "Catlikes");

            var d = new MongoRepository<Dog>();
            var dm = new MongoRepositoryManager<Dog>();
            var vd = new Dog();
            //Assert.IsFalse(dm.Exists);
            d.Update(vd);
            Assert.IsTrue(dm.Exists);
            Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog));
            Assert.AreEqual(dm.Name, "AnimalsTest");
            Assert.AreEqual(d.CollectionName, "AnimalsTest");

            var m = new MongoRepository<Bird>();
            var mm = new MongoRepositoryManager<Bird>();
            var vm = new Macaw();
            //Assert.IsFalse(mm.Exists);
            m.Update(vm);
            Assert.IsTrue(mm.Exists);
            Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw));
            Assert.AreEqual(mm.Name, "Birds");
            Assert.AreEqual(m.CollectionName, "Birds");

            var w = new MongoRepository<Whale>();
            var wm = new MongoRepositoryManager<Whale>();
            var vw = new Whale();
            Assert.IsFalse(wm.Exists);
            w.Update(vw);
            Assert.IsTrue(wm.Exists);
            Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale));
            Assert.AreEqual(wm.Name, "Whale");
            Assert.AreEqual(w.CollectionName, "Whale");
        }
Esempio n. 18
0
        public void CollectionNamesTest()
        {
            // animal
            var a  = new MongoRepository <Animal>();
            var am = new MongoRepositoryManager <Animal>();

            a.DeleteAll();

            var va = new Dog();

            am.Exists.ShouldBeFalse();
            a.Update(va);
            am.Exists.ShouldBeTrue();
            a.GetById(va.Id).ShouldBeOfType(typeof(Dog));
            am.Name.ShouldBe("AnimalsTest");
            a.CollectionName.ShouldBe("AnimalsTest");

            // cat
            var cl  = new MongoRepository <CatLike>();
            var clm = new MongoRepositoryManager <CatLike>();

            cl.DeleteAll();

            var vcl = new Lion();

            clm.Exists.ShouldBeFalse();
            cl.Update(vcl);
            clm.Exists.ShouldBeTrue();
            cl.GetById(vcl.Id).ShouldBeOfType(typeof(Lion));
            clm.Name.ShouldBe("Catlikes");
            cl.CollectionName.ShouldBe("Catlikes");

            // bird
            var b  = new MongoRepository <Bird>();
            var bm = new MongoRepositoryManager <Bird>();

            b.DeleteAll();

            var vb = new Bird();

            bm.Exists.ShouldBeFalse();
            b.Update(vb);
            bm.Exists.ShouldBeTrue();
            b.GetById(vb.Id).ShouldBeOfType(typeof(Bird));
            bm.Name.ShouldBe("Birds");
            b.CollectionName.ShouldBe("Birds");

            // lion
            var l  = new MongoRepository <Lion>();
            var lm = new MongoRepositoryManager <Lion>();

            l.DeleteAll();

            var vl = new Lion();

            //Assert.IsFalse(lm.Exists);   //Should already exist (created by cl)
            l.Update(vl);
            lm.Exists.ShouldBeTrue();
            l.GetById(vl.Id).ShouldBeOfType(typeof(Lion));
            lm.Name.ShouldBe("Catlikes");
            l.CollectionName.ShouldBe("Catlikes");

            // dog
            var d  = new MongoRepository <Dog>();
            var dm = new MongoRepositoryManager <Dog>();

            d.DeleteAll();

            var vd = new Dog();

            //Assert.IsFalse(dm.Exists);
            d.Update(vd);
            dm.Exists.ShouldBeTrue();
            d.GetById(vd.Id).ShouldBeOfType(typeof(Dog));
            dm.Name.ShouldBe("AnimalsTest");
            d.CollectionName.ShouldBe("AnimalsTest");

            // bird
            var m  = new MongoRepository <Bird>();
            var mm = new MongoRepositoryManager <Bird>();

            m.DeleteAll();

            var vm = new Macaw();

            m.Update(vm);
            mm.Exists.ShouldBeTrue();
            m.GetById(vm.Id).ShouldBeOfType(typeof(Macaw));
            mm.Name.ShouldBe("Birds");
            m.CollectionName.ShouldBe("Birds");

            // whale
            var w  = new MongoRepository <Whale>();
            var wm = new MongoRepositoryManager <Whale>();

            w.DeleteAll();

            var vw = new Whale();

            wm.Exists.ShouldBeFalse();
            w.Update(vw);
            wm.Exists.ShouldBeTrue();
            w.GetById(vw.Id).ShouldBeOfType(typeof(Whale));
            wm.Name.ShouldBe("Whale");
            w.CollectionName.ShouldBe("Whale");

            // cleanup
            am.Drop();
            clm.Drop();
            bm.Drop();
            lm.Drop();
            dm.Drop();
            mm.Drop();
            wm.Drop();
        }
        public async void NotExistsAsync()
        {
            var em = new MongoRepositoryManager <Product>(MongoUrl);

            Assert.False(await em.ExistsAsync());
        }
        public void NotExists()
        {
            var em = new MongoRepositoryManager <Product>(MongoUrl);

            Assert.False(em.Exists());
        }
Esempio n. 21
0
 public void CanCreateIndexByString()
 {
     var manager = new MongoRepositoryManager <Customer>();
     // var index = manager.EnsureIndex("Email", true, true, true);
     // manager.DropIndex(index);
 }
        public void CollectionNamesTest()
        {
            var a  = new MongoRepository <Animal>();
            var am = new MongoRepositoryManager <Animal>();
            var va = new Dog();

            Assert.IsFalse(am.Exists);
            a.Update(va);
            Assert.IsTrue(am.Exists);
            Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog));
            Assert.AreEqual(am.Name, "AnimalsTest");
            Assert.AreEqual(a.CollectionName, "AnimalsTest");

            var cl  = new MongoRepository <CatLike>();
            var clm = new MongoRepositoryManager <CatLike>();
            var vcl = new Lion();

            Assert.IsFalse(clm.Exists);
            cl.Update(vcl);
            Assert.IsTrue(clm.Exists);
            Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion));
            Assert.AreEqual(clm.Name, "Catlikes");
            Assert.AreEqual(cl.CollectionName, "Catlikes");

            var b  = new MongoRepository <Bird>();
            var bm = new MongoRepositoryManager <Bird>();
            var vb = new Bird();

            Assert.IsFalse(bm.Exists);
            b.Update(vb);
            Assert.IsTrue(bm.Exists);
            Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird));
            Assert.AreEqual(bm.Name, "Birds");
            Assert.AreEqual(b.CollectionName, "Birds");

            var l  = new MongoRepository <Lion>();
            var lm = new MongoRepositoryManager <Lion>();
            var vl = new Lion();

            //Assert.IsFalse(lm.Exists);   //Should already exist (created by cl)
            l.Update(vl);
            Assert.IsTrue(lm.Exists);
            Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion));
            Assert.AreEqual(lm.Name, "Catlikes");
            Assert.AreEqual(l.CollectionName, "Catlikes");

            var d  = new MongoRepository <Dog>();
            var dm = new MongoRepositoryManager <Dog>();
            var vd = new Dog();

            //Assert.IsFalse(dm.Exists);
            d.Update(vd);
            Assert.IsTrue(dm.Exists);
            Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog));
            Assert.AreEqual(dm.Name, "AnimalsTest");
            Assert.AreEqual(d.CollectionName, "AnimalsTest");

            var m  = new MongoRepository <Bird>();
            var mm = new MongoRepositoryManager <Bird>();
            var vm = new Macaw();

            //Assert.IsFalse(mm.Exists);
            m.Update(vm);
            Assert.IsTrue(mm.Exists);
            Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw));
            Assert.AreEqual(mm.Name, "Birds");
            Assert.AreEqual(m.CollectionName, "Birds");

            var w  = new MongoRepository <Whale>();
            var wm = new MongoRepositoryManager <Whale>();
            var vw = new Whale();

            Assert.IsFalse(wm.Exists);
            w.Update(vw);
            Assert.IsTrue(wm.Exists);
            Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale));
            Assert.AreEqual(wm.Name, "Whale");
            Assert.AreEqual(w.CollectionName, "Whale");
        }