示例#1
0
        public void DeleteByID()
        {
            var manager = new ComicStripManager(new UnitOfWork("development"));

            manager.DeleteAll();
            var publisherManager = new PublisherManager(new UnitOfWork("development"));

            publisherManager.DeleteAll();
            publisherManager.Add(new Publisher("test-publisher"));

            var AuthorManager = new AuthorManager(new UnitOfWork("development"));

            AuthorManager.DeleteAll();
            AuthorManager.Add(new Author("test-author", "test-author"));

            manager.Add(new BusinessLayer.Models.ComicStrip("test-strip", new ComicstripSerie("testSerie"), 5, AuthorManager.GetAll(), publisherManager.GetAll()[0]));
            var comic = manager.GetAll();

            Assert.AreEqual(comic.Count, 1);
            var comc = manager.Get(comic[0].ID);

            Assert.AreEqual(comc.Titel, "test-strip");
            Assert.AreEqual(comc.Number, 5);
            manager.Delete(comc.ID);
            comic = manager.GetAll();
            Assert.AreEqual(comic.Count, 0);

            publisherManager.DeleteAll();
            AuthorManager.DeleteAll();
            manager.DeleteAll();
        }
        public void Get()
        {
            var manager = new ComicStripManager(new UnitOfWork("development"));

            manager.DeleteAll();
            var publisherManager = new PublisherManager(new UnitOfWork("development"));

            publisherManager.DeleteAll();
            publisherManager.Add(new Publisher("test-publisher"));

            var AuthorManager = new AuthorManager(new UnitOfWork("development"));

            AuthorManager.DeleteAll();

            AuthorManager.Add(new Author("test-author", "test-author"));

            manager.Add(new BusinessLayer.Models.ComicStrip("test-strip", new ComicstripSerie("testSerie"), 5, AuthorManager.GetAll(), publisherManager.GetAll()[0]));
            var comic = manager.GetAll();

            var bundleManager = new ComicstripBundleManager(new UnitOfWork("development"));

            bundleManager.DeleteAll();
            bundleManager.Add(new ComicstripBundle("test-bundle", comic, publisherManager.GetAll()[0]));
            var bundles = bundleManager.GetAll();
            var bundle  = bundleManager.Get(bundles[0].ID);

            Assert.AreEqual(bundles.Count, 1);
            Assert.AreEqual(bundle.Titel, "test-bundle");
            Assert.AreEqual(bundle.Comicstrips.Count, 1);

            manager.DeleteAll();
            AuthorManager.DeleteAll();
            bundleManager.DeleteAll();
        }