public void WhenDeleteCalledForNonexistentPhoto_ThenThrows()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();
            var repository = new VehiclePhotoRepository(new MileageStatsDbContext());

            Assert.Throws<InvalidOperationException>(() => repository.Delete(12345));
        }
        public void WhenCreateCalled_ThenPhotoPersists()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();
            var repository = new VehiclePhotoRepository(new MileageStatsDbContext());
            var photo = new Model.VehiclePhoto()
                            {
                                ImageMimeType = "image/jpeg",
                                Image = new byte[1]
                            };
            repository.Create(1, photo);

            var repository2 = new VehiclePhotoRepository(new MileageStatsDbContext());
            Assert.NotNull(repository2.Get(1));
        }
        public void WhenDeleteCalled_ThenPhotoNuked()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();
            var repository = new VehiclePhotoRepository(new MileageStatsDbContext());
            var photo = new Model.VehiclePhoto()
                            {
                                ImageMimeType = "image/jpeg",
                                Image = new byte[1]
                            };
            repository.Create(1, photo);

            var photoToEdit = repository.Get(1);
            repository.Delete(photoToEdit.VehiclePhotoId);

            var repository2 = new VehiclePhotoRepository(new MileageStatsDbContext());
            Assert.Throws<InvalidOperationException>(() => repository2.Get(1));
        }
        public void WhenGetCalled_ThenReturnsPhoto()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();

            using (var dbContext = new MileageStatsDbContext())
            {
                var photo = new Model.VehiclePhoto()
                                {
                                    ImageMimeType = "image/jpeg",
                                    Image = new byte[1]
                                };

                dbContext.VehiclePhotos.Add(photo);
                dbContext.SaveChanges();
            }

            VehiclePhotoRepository target = new VehiclePhotoRepository(new MileageStatsDbContext());

            var actual = target.Get(1);

            Assert.NotNull(actual);
        }
 public void WhenConstructedWithNullUnitOfWork_ThenThrows()
 {
     Assert.Throws<ArgumentNullException>(
         () => { var repository = new VehiclePhotoRepository(null); });
 }
        public void WhenConstuctedWithUnitOfWork_ThenSuccessful()
        {
            VehiclePhotoRepository actual = new VehiclePhotoRepository(new MileageStatsDbContext());

            Assert.NotNull(actual);
        }
        public void WhenGetCalledForNonExistantPhoto_ThenThrowsInvalidOperationException()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();

            VehiclePhotoRepository target = new VehiclePhotoRepository(new MileageStatsDbContext());

            Assert.Throws<InvalidOperationException>(() => target.Get(1200));
        }