Beispiel #1
0
        public void GetByWrongId_Null()
        {
            // Arrange
            PhotoRepository photoRepository     = new PhotoRepository(dbContext);
            Guid            wrongId             = default(Guid);
            Photo           expectedPhotoFromDb = null;

            // Act
            Photo actualPhotoFromDb = photoRepository.Get(wrongId);

            // Assert
            Assert.AreEqual(expectedPhotoFromDb, actualPhotoFromDb);
        }
Beispiel #2
0
        public void GetById()
        {
            // Arrange
            PhotoRepository photoRepository = new PhotoRepository(dbContext);
            Guid            idToSearch      = dbContext.Photos.First().Id;
            Photo           expectedPhoto   = dbContext.Photos.Find(idToSearch);

            // Act
            Photo photosFromDb = photoRepository.Get(idToSearch);

            // Assert
            Assert.AreEqual(expectedPhoto, photosFromDb);
        }
Beispiel #3
0
        public void GetAll()
        {
            // Arrange
            PhotoRepository photoRepository   = new PhotoRepository(dbContext);
            int             expectedPhotoInDb = Resources.Classes.DbFiller.Instance.PhotoAmount;

            // Act
            Photo[] photosFromDb    = photoRepository.Get().ToArray();
            int     actualPhotoInDb = photosFromDb.Length;

            // Assert
            Assert.AreEqual(expectedPhotoInDb, actualPhotoInDb);
            CollectionAssert.AreEquivalent(dbContext.Photos.ToArray(), photosFromDb);
        }
Beispiel #4
0
        public void GetOrder()
        {
            // Arrange
            PhotoRepository photoRepository   = new PhotoRepository(dbContext);
            int             expectedPhotoInDb = Resources.Classes.DbFiller.Instance.PhotoAmount;

            // Act
            Photo[] photosFromDb    = photoRepository.Get(orderBy: photo => photo.OrderBy(p => p.Path)).ToArray();
            int     actualPhotoInDb = photosFromDb.Length;

            // Assert
            Assert.AreEqual(expectedPhotoInDb, actualPhotoInDb);
            CollectionAssert.AreEqual(dbContext.Photos.OrderBy(p => p.Path).ToArray(), photosFromDb);
        }
Beispiel #5
0
        public void GetFilterByUserNickName()
        {
            // Arrange
            PhotoRepository photoRepository   = new PhotoRepository(dbContext);
            string          userNickname      = Resources.Classes.DbFiller.Instance.FirstUserNickname;
            int             expectedPhotoInDb = Resources.Classes.DbFiller.Instance.GetPhotoAmountByUser(userNickname);

            // Act
            Photo[] photosFromDb    = photoRepository.Get(filter: photo => photo.User.NickName == userNickname).ToArray();
            int     actualPhotoInDb = photosFromDb.Length;

            // Assert
            Assert.AreEqual(expectedPhotoInDb, actualPhotoInDb);
            CollectionAssert.IsSubsetOf(photosFromDb, dbContext.Photos.ToArray());
        }
Beispiel #6
0
        public void GetFilterAndOrder()
        {
            if (Core.Configuration.TestConfig.DATABASE_FILL_MODE == Core.Enums.DataBaseFillMode.Regular)
            {
                // Arrange
                PhotoRepository photoRepository   = new PhotoRepository(dbContext);
                int             expectedPhotoInDb = 3;
                Photo[]         valueInDataBase   = dbContext.Photos.Where(p => p.User.NickName == "John").OrderByDescending(p => p.Path).ToArray();

                // Act
                Photo[] photosFromDb    = photoRepository.Get(filter: p => p.User.NickName == "John", orderBy: o => o.OrderByDescending(p => p.Path)).ToArray();
                int     actualPhotoInDb = photosFromDb.Length;

                // Assert
                Assert.AreEqual(expectedPhotoInDb, actualPhotoInDb);
                CollectionAssert.AreEqual(valueInDataBase, photosFromDb.ToArray());
            }
        }
Beispiel #7
0
        public void GetPhotoTest()
        {
            Photo photo = _photoRepository.Get(11, true);

            Assert.IsNotNull(photo.Title);
        }
Beispiel #8
0
        // GET: Photo/Details/5
        public ActionResult List(Guid id) // Album Id
        {
            var photos = PhotoRepository.Get(id);

            return(PartialView("List", photos.ToModel()));
        }