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 WhenGetCalledForNonExistantPhoto_ThenThrowsInvalidOperationException()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();

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

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