예제 #1
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
        }
예제 #2
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));
        }
예제 #3
0
        void AddAlbum()
        {
            var album = new AlbumDetailModel();

            album.Name = AlbumName;
            albumRepository.Insert(album);
            OnLoad();
            messenger.Send(new AlbumListUpdatedMessage());
        }
예제 #4
0
파일: Mapper.cs 프로젝트: Michal696/Gallery
 public AlbumEntity MapAlbumDetailModelToAlbumEntity(AlbumDetailModel model)
 {
     return(new AlbumEntity()
     {
         Id = model.Id,
         Name = model.Name,
         Photos = model.Photos
     });
 }
예제 #5
0
 public AlbumEntity MapToEntity(AlbumDetailModel detail)
 {
     return(new AlbumEntity()
     {
         Id = detail.Id,
         Name = detail.Name,
         Description = detail.Description,
         PictureCollection = detail.PictureCollection.Select(_picMapper.MapToEntity).ToList()
     });
 }
예제 #6
0
        public AlbumDetailModel Insert(AlbumDetailModel detail)
        {
            using (var galleryDbContext = new GalleryDbContext())
            {
                var entity = mapper.MapAlbumDetailModelToAlbumEntity(detail);
                entity.Id = Guid.NewGuid();
                galleryDbContext.Albums.Add(entity);
                galleryDbContext.SaveChanges();

                return(mapper.MapAlbumEntityToAlbumDetailModel(entity));
            }
        }
예제 #7
0
        public ActionResult AlbumDetail()
        {
            AlbumDetailModel albumModel = new AlbumDetailModel();

            try
            {
                ViewBag.CardMessage = "Album Added Successfully.";
            }
            catch (Exception e)
            {
            }
            return(View(albumModel));
        }
예제 #8
0
        public AlbumDetailModel Insert(AlbumDetailModel albumDetail)
        {
            using (var context = new PhotoLibraryDbContext())
            {
                var albumEntity = mapper.DetailModelToEntity(albumDetail);
                albumEntity.Id = Guid.NewGuid();

                context.Albums.Add(albumEntity);
                context.SaveChanges();

                return(mapper.EntityToDetailModel(albumEntity));
            }
        }
예제 #9
0
        public void Update(AlbumDetailModel albumDetail)
        {
            using (var context = new PhotoLibraryDbContext())
            {
                var albumEntity = context.Albums.First(a => a.Id == albumDetail.Id);

                albumEntity.Name        = albumDetail.Name;
                albumEntity.DateTime    = albumDetail.DateTime;
                albumEntity.Description = albumDetail.Description;

                context.SaveChanges();
            }
        }
예제 #10
0
 public AlbumListModel DetailModelToListModel(AlbumDetailModel album)
 {
     if (album == null)
     {
         return(null);
     }
     return(new AlbumListModel
     {
         Id = album.Id,
         Name = album.Name,
         DateTime = album.DateTime,
         Description = album.Description
     });
 }
예제 #11
0
 public Album DetailModelToEntity(AlbumDetailModel album)
 {
     if (album == null)
     {
         return(null);
     }
     return(new Album()
     {
         Id = album.Id,
         Name = album.Name,
         DateTime = album.DateTime,
         Description = album.Description
     });
 }
예제 #12
0
        public ActionResult AlbumDetail(AlbumDetailModel model)
        {
            AlbumServiceModel albumEntity = new AlbumServiceModel();

            albumEntity.AlbumName   = model.AlbumName;
            albumEntity.Artist      = model.Artist;
            albumEntity.Genre       = model.Genre;
            albumEntity.CreatedBy   = "Vivek";
            albumEntity.DateCreated = DateTime.Now;
            albumEntity.UpdatedBy   = "Vivek";
            albumEntity.DateUpdated = DateTime.Now;

            _mvcsService.InsertAlbum(albumEntity);
            return(RedirectToAction("Home", "AlbumHome"));
        }
예제 #13
0
 private void DeleteAlbum()
 {
     if (Detail.Id != Guid.Empty)
     {
         var result = MessageBox.Show("Naozaj chcete vymazať tento album ? ", "Vymazanie albumu", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.No)
         {
             return;
         }
         var detailId = Detail.Id;
         Detail = new AlbumDetailModel();
         albumRepository.Delete(detailId);
         messenger.Send(new DeleteAlbumMessage(detailId));
     }
 }
예제 #14
0
        public void AlbumInsert()
        {
            var detail = new AlbumDetailModel()
            {
                Name   = "TestInsertAlbum",
                Photos = new List <PhotoEntity>()
            };
            var album = albumRepositorySUT.Insert(detail);

            Assert.NotNull(album);

            using (var context = new GalleryDbContext())
            {
                Assert.Contains(context.Albums, x => x.Id == album.Id);
            }
        }
예제 #15
0
        public void TestInsert()
        {
            var model = new AlbumDetailModel
            {
                Description = "Test model for testing method",
                Name        = "Test Model"
            };
            var inserted = _repository.Insert(model);
            var fouded   = _repository.GetById(inserted.Id);

            Assert.Equal(model.Description, inserted.Description);
            Assert.Equal(model.Name, inserted.Name);
            Assert.NotNull(inserted.Id);
            Assert.Equal(fouded.Id, inserted.Id);
            Assert.Equal(fouded.Name, inserted.Name);
            Assert.Equal(fouded.Description, inserted.Description);
            Assert.Equal(fouded.PictureCollection.Count, inserted.PictureCollection.Count);
        }
예제 #16
0
        public void AlbumRemove()
        {
            var detail = new AlbumDetailModel()
            {
                Id     = Guid.NewGuid(),
                Name   = "TestovaciAlbum",
                Photos = new List <PhotoEntity>()
            };
            var album = albumRepositorySUT.Insert(detail);

            Assert.NotNull(album);

            albumRepositorySUT.Remove(detail.Id);

            using (var context = new GalleryDbContext())
            {
                Assert.DoesNotContain(context.Albums, x => x.Id == detail.Id);
            }
        }
예제 #17
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
        }
예제 #18
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)));
        }
예제 #19
0
 private void NewAlbumMessageReceived(NewMessage obj)
 {
     Detail = new AlbumDetailModel();
 }
예제 #20
0
 public UpdatedAlbumMessage(AlbumDetailModel model)
 {
     Model = model;
 }
예제 #21
0
 private void NewAlbumMessageRecieved(NewAlbumMessage message)
 {
     Detail = new AlbumDetailModel();
 }