예제 #1
0
        public void WhenDeleteCalledForNonexistentPhoto_ThenThrows()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();
            var repository = new VehiclePhotoRepository(new MileageStatsDbContext());

            Assert.Throws <InvalidOperationException>(() => repository.Delete(12345));
        }
예제 #2
0
        public void WhenGetCalledForNonExistantPhoto_ThenThrowsInvalidOperationException()
        {
            DatabaseTestUtility.DropCreateMileageStatsDatabase();

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

            Assert.Throws <InvalidOperationException>(() => target.Get(1200));
        }
        public void WhenCreateCalled_ThenPhotoPersists()
        {
            var repository = new VehiclePhotoRepository();
            var photo = new VehiclePhoto
                            {
                                ImageMimeType = "image/jpeg",
                                Image = new byte[1]
                            };
            repository.Create(1, photo);

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

            repository.Create(1, photo);

            var repository2 = new VehiclePhotoRepository();

            Assert.NotNull(repository2.Get(1));
        }
        public void WhenDeleteCalled_ThenPhotoNuked()
        {
            const int vehicleId = 1;
            var repository = new VehiclePhotoRepository();
            var photo = new VehiclePhoto
                            {
                                ImageMimeType = "image/jpeg",
                                Image = new byte[1]
                            };
            repository.Create(vehicleId, photo);
            repository.Delete(photo.Id);

            var repository2 = new VehiclePhotoRepository();
            Assert.Null(repository2.Get(photo.Id));
        }
예제 #6
0
        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()
        {
            const int vehicleId  = 1;
            var       repository = new VehiclePhotoRepository();
            var       photo      = new VehiclePhoto
            {
                ImageMimeType = "image/jpeg",
                Image         = new byte[1]
            };

            repository.Create(vehicleId, photo);
            repository.Delete(photo.Id);

            var repository2 = new VehiclePhotoRepository();

            Assert.Null(repository2.Get(photo.Id));
        }
        public void WhenGetCalled_ThenReturnsPhoto()
        {
            const int vehicleId = 99;

            new VehiclePhotoRepository()
            .Create(
                vehicleId,
                new VehiclePhoto
            {
                ImageMimeType = "image/jpeg",
                Image         = new byte[1]
            });


            var target = new VehiclePhotoRepository();

            var actual = target.Get(vehicleId);

            Assert.NotNull(actual);
        }
예제 #9
0
        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));
        }
예제 #10
0
        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 WhenDeleteCalledForNonexistentPhoto_ThenThrows()
        {
            var repository = new VehiclePhotoRepository();

            Assert.Throws<InvalidOperationException>(() => repository.Delete(12345));
        }
        public void WhenConstuctedWithUnitOfWork_ThenSuccessful()
        {
            var actual = new VehiclePhotoRepository();

            Assert.NotNull(actual);
        }
        public void WhenGetCalledForNonExistantPhoto_ThenReturnsNull()
        {
            var target = new VehiclePhotoRepository();

            Assert.Null(target.Get(1200));
        }
        public void WhenGetCalled_ThenReturnsPhoto()
        {
            const int vehicleId = 99;
            new VehiclePhotoRepository()
                .Create(
                    vehicleId,
                    new VehiclePhoto
                        {
                            ImageMimeType = "image/jpeg",
                            Image = new byte[1]
                        });


            var target = new VehiclePhotoRepository();

            var actual = target.Get(vehicleId);
            Assert.NotNull(actual);
        }
예제 #15
0
 public void WhenConstructedWithNullUnitOfWork_ThenThrows()
 {
     Assert.Throws <ArgumentNullException>(
         () => { var repository = new VehiclePhotoRepository(null); });
 }
예제 #16
0
        public void WhenConstuctedWithUnitOfWork_ThenSuccessful()
        {
            VehiclePhotoRepository actual = new VehiclePhotoRepository(new MileageStatsDbContext());

            Assert.NotNull(actual);
        }
        public void WhenGetCalledForNonExistantPhoto_ThenReturnsNull()
        {
            var target = new VehiclePhotoRepository();

            Assert.Null(target.Get(1200));
        }
        public void WhenConstuctedWithUnitOfWork_ThenSuccessful()
        {
            var actual = new VehiclePhotoRepository();

            Assert.NotNull(actual);
        }
        public void WhenDeleteCalledForNonexistentPhoto_ThenThrows()
        {
            var repository = new VehiclePhotoRepository();

            Assert.Throws <InvalidOperationException>(() => repository.Delete(12345));
        }