Example #1
0
        public ActionResult Index()
        {
            var context = new PhotoSharingContext();

            var a = context.Photos.ToList();

            return(View());
        }
Example #2
0
        public void CreateDatabase()
        {
            Initialiser.SetInitialiser();

            var context = new PhotoSharingContext();

            var albums = context.Albums.ToList();

            Assert.IsNotNull(albums);
        }
Example #3
0
        public void IndexReturnsView()
        {
            var options = CreateNewContextOptions();

            // Run the test against one instance of the context
            using (var context = new PhotoSharingContext(options))
            {
                using (PhotosController controller = new PhotosController(context))
                {
                    var result = (controller.Index()) as ViewResult;
                    Assert.Equal(nameof(controller.Index), result.ViewName);
                }
            }
        }
Example #4
0
        public async void GetImageReturnsFile(int id)
        {
            var options = CreateNewContextOptions();

            // Run the test against one instance of the context
            using (var context = new PhotoSharingContext(options))
            {
                using (PhotosController controller = new PhotosController(context))
                {
                    var photos = new List <Photo>
                    {
                        new Photo {
                            Title         = "Me standing on top of a mountain",
                            Description   = "I was very impressed with myself",
                            UserName      = "******",
                            PhotoFile     = new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 },
                            ImageMimeType = "image/jpeg",
                            CreatedDate   = DateTime.Today
                        },
                        new Photo {
                            Title         = "My New Adventure Works Bike",
                            Description   = "It's the bees knees!",
                            UserName      = "******",
                            PhotoFile     = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 },
                            ImageMimeType = "image/jpeg",
                            CreatedDate   = DateTime.Today
                        },
                        new Photo {
                            Title         = "View from the start line",
                            Description   = "I took this photo just before we started over my handle bars.",
                            UserName      = "******",
                            PhotoFile     = new byte[] { 255, 255, 255, 255, 0, 0, 0, 0 },
                            ImageMimeType = "image/jpeg",
                            CreatedDate   = DateTime.Today
                        }
                    };
                    photos.ForEach(s => context.Photos.Add(s));
                    context.SaveChanges();

                    var result = (await controller.GetImage(id)) as ActionResult;

                    Assert.Equal(typeof(FileContentResult), result.GetType());
                }
            }
        }
Example #5
0
 public BaseRepository(PhotoSharingContext photoSharingContext)
 {
     this.photoSharingContext = photoSharingContext;
 }
Example #6
0
 public BaseRepository()
 {
     photoSharingContext = new PhotoSharingContext();
 }
Example #7
0
 public CreateACommentViewComponent(PhotoSharingContext context)
 {
     this._context = context;
 }
 public PhotosController(PhotoSharingContext context)
 {
     _context = context;
 }
        public PhotoController()
        {
            PhotoSharingContext photoSharingContext = new PhotoSharingContext();

            context = photoSharingContext;
        }
Example #10
0
 public CommentsForPhotoViewComponent(PhotoSharingContext context)
 {
     this._context = context;
 }
Example #11
0
 public DefaultRepository()
 {
     this.context = new PhotoSharingContext();
 }
 public CommentsController(PhotoSharingContext Context)
 {
     _context = Context;
 }
 public PhotosController(PhotoSharingContext context, IMemoryCache memoryCache)
 {
     _context     = context;
     _memoryCache = memoryCache;
 }
 public PhotoGalleryViewComponent(PhotoSharingContext context)
 {
     this._context = context;
 }