public void Drop()
        {
            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());
            productManager.Drop();
            Assert.False(productManager.Exists());
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
 public void SetUp()
 {
     // Drop the Categories collection
     _collectionManager.Drop();
 }