示例#1
0
        public void Delete_Photo()
        {
            Photo photo = new Photo
            {
                DateTime   = DateTime.Now,
                Name       = "testPhoto",
                FileFormat = FileFormat.gif,
                Path       = "My/path/to/file",
                Id         = AddNewGuid()
            };
            AlbumDetailModel album = new AlbumDetailModel()
            {
                DateTime    = DateTime.Now,
                Description = "Description",
                Id          = TestGuidList.ElementAt(0),
                Name        = "TmpAlbum1",
                Photos      = new List <PhotoListModel> {
                    mapper.EntityToListModel(photo)
                }
            };

            photo.Album = mapper.DetailModelToEntity(album);
            albumRepo.Insert(album);
            photoRepo.Insert(mapper.EntityToDetailModel(photo), album.Id);

            photoRepo.Delete(photo.Id);

            Assert.Null(photoRepo.GetById(photo.Id));
            Assert.NotNull(albumRepo.GetById(album.Id));
        }
示例#2
0
        public void Update_Album_NoPhotos()
        {
            DateTime dt = DateTime.MaxValue;
            //set up
            AlbumDetailModel album = new AlbumDetailModel()
            {
                DateTime    = dt,
                Description = "Description",
                Id          = TestGuidList.ElementAt(0),
                Name        = "TmpAlbum",
                Photos      = null
            };

            albumRepo.Insert(album);

            AlbumDetailModel updatedAlbum = new AlbumDetailModel()
            {
                DateTime    = dt,
                Description = "Very descriptive description",
                Id          = TestGuidList.ElementAt(0),
                Name        = "new TmpAlbum",
                Photos      = null
            };

            //unit test
            albumRepo.Update(updatedAlbum);

            //Assert
            var albumFromDB = albumRepo.GetById(TestGuidList.ElementAt(0));

            Assert.Equal(updatedAlbum.Description, albumFromDB.Description);

            //tear down
        }
示例#3
0
        public void Delete_Album_NoPhotos()
        {
            //set up
            AlbumDetailModel album = new AlbumDetailModel()
            {
                DateTime    = DateTime.Now,
                Description = "Description",
                Id          = TestGuidList.ElementAt(0),
                Name        = "TmpAlbum",
                Photos      = null
            };

            albumRepo.Insert(album);

            //unit test
            albumRepo.Delete(TestGuidList.ElementAt(0));

            //Assert
            Assert.Null(albumRepo.GetById(TestGuidList.ElementAt(0)));
        }
示例#4
0
        public void Insert_Album_NoPhotos()
        {
            //Set up
            AlbumDetailModel album = new AlbumDetailModel()
            {
                DateTime    = DateTime.Now,
                Description = "Description",
                Id          = TestGuidList.ElementAt(0),
                Name        = "TmpAlbum",
                Photos      = null
            };

            //Unit Test
            albumRepo.Insert(album);

            //Assert
            Assert.NotNull(albumRepo.GetById(TestGuidList.ElementAt(0)));

            //Tear down
        }
示例#5
0
        public void GetById_Album_IsNull()
        {                                           //Unknown GUID
            var album = albumRepo.GetById(TestGuidList.ElementAt(0));

            Assert.Null(album);
        }