Exemplo n.º 1
0
        public void AddMediaItemTest()
        {
            MediaItem media = new MediaItem
            {
                Name = "patrickstar",
                Title = "Patrick Star",
                Type = MediaType.Image,
                Format = MediaFormat.JPG,
                AlternativeText = "Patricio Estrella",
                Bytes = TestData.GetResourceBytes("Babel.Services.Tests.media.patrickstar.jpg"),
                Owner = TestData.profiles[1]
            };

            MediaRepository repository = new MediaRepository();
            Guid guid = repository.Add(media);

            Assert.AreNotEqual<Guid>(Guid.Empty, guid);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var mediaFromDB = session.Get<MediaItem>(media.ID);

                Assert.IsNotNull(mediaFromDB);
                Assert.AreNotSame(media, mediaFromDB);
                Assert.AreEqual<string>(media.Name, mediaFromDB.Name);
                Assert.AreEqual<string>(media.Title, mediaFromDB.Title);
                Assert.AreEqual<MediaType>(media.Type, mediaFromDB.Type);
                Assert.AreEqual<MediaFormat>(media.Format, mediaFromDB.Format);
                Assert.AreEqual<string>(media.AlternativeText, mediaFromDB.AlternativeText);
            }
        }
Exemplo n.º 2
0
        public void UpdateMediaItemTest()
        {
            MediaItem media = TestData.mediaItems[0];
            media.Name = "loreena-fullcircle";
            media.Title = "Loreena McKennitt - Full Circle";
            media.AlternativeText = "Loreena McKennitt - The Mask and the Mirror - Full Circle";
            media.Owner = TestData.profiles[1];

            IMediaRepository repository = new MediaRepository();
            repository.Update(media);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var mediaFromDB = session.Get<MediaItem>(media.ID);

                Assert.IsNotNull(mediaFromDB);
                Assert.AreEqual<string>(media.Name, mediaFromDB.Name);
                Assert.AreEqual<string>(media.Title, mediaFromDB.Title);
                Assert.AreEqual<string>(media.AlternativeText, mediaFromDB.AlternativeText);
                Assert.AreEqual<Guid>(media.Owner.ID, mediaFromDB.Owner.ID);
            }
        }
Exemplo n.º 3
0
        public void SearchMediaItemsTest()
        {
            IMediaRepository repository = new MediaRepository();

            MediaItemFilter filter = new MediaItemFilter()
            {
                Name = "spoungebob",
                Type = MediaType.Image
            };

            IList<MediaItem> searchResult = repository.SearchMediaItems(filter);

            Assert.AreEqual<int>(1, searchResult.Count);
            Assert.AreEqual<string>("spoungebob", searchResult[0].Name);
            Assert.AreEqual<string>("Bob Esponja", searchResult[0].Title);
            Assert.AreEqual<MediaType>(MediaType.Image, searchResult[0].Type);
            Assert.AreEqual<MediaFormat>(MediaFormat.JPG, searchResult[0].Format);
        }
Exemplo n.º 4
0
        public void RemoveMediaItemTest()
        {
            IMediaRepository repository = new MediaRepository();
            repository.Remove(TestData.mediaItems[2]);

            using (ISession session = _sessionFactory.OpenSession())
            {
                MediaItem mediaFromDB = session.Get<MediaItem>(TestData.mediaItems[2].ID);

                Assert.IsNull(mediaFromDB);
            }
        }
Exemplo n.º 5
0
        public void GetMediaItemByIDTest()
        {
            IMediaRepository repository = new MediaRepository();
            MediaItem mediaFromDB = repository.GetMediaItemByID(TestData.mediaItems[0].ID);

            Assert.IsNotNull(mediaFromDB);
            Assert.AreEqual<Guid>(TestData.mediaItems[0].ID, mediaFromDB.ID);
            Assert.AreEqual<string>(TestData.mediaItems[0].Name, mediaFromDB.Name);
            Assert.AreEqual<string>(TestData.mediaItems[0].Title, mediaFromDB.Title);
            Assert.AreEqual<string>(TestData.mediaItems[0].AlternativeText, mediaFromDB.AlternativeText);
            Assert.AreEqual<Guid>(TestData.mediaItems[0].Owner.ID, mediaFromDB.Owner.ID);
        }
Exemplo n.º 6
0
        public void GetAllMediaItemsTest()
        {
            IMediaRepository repository = new MediaRepository();
            IList<MediaItem> allMediaItems = repository.GetAllMediaItems();

            Assert.IsNotNull(allMediaItems);
            Assert.AreEqual<int>(3, allMediaItems.Count);
        }