Example #1
0
        public async void Details_ShowsCorrectView()
        {
            Repository.Setup(v => v.GetByIdAsync(1)).ReturnsAsync(VenueGenerator.Create());
            var result = await Controller.Delete(1);

            Assert.IsType <ViewResult>(result);
            var viewResult = result as ViewResult;

            Assert.Null(viewResult.ViewName);
        }
Example #2
0
        public async void DeleteConfirmed_DeletesVenue()
        {
            var venue = VenueGenerator.Create();

            var result = await Controller.DeleteConfirmed(venue.VenueId);

            Assert.IsType <RedirectToActionResult>(result);

            var redirectedResult = result as RedirectToActionResult;

            Assert.Equal("Index", redirectedResult.ActionName);

            Repository.Verify();
        }
Example #3
0
        public async void Delete_ContainsCorrectModel()
        {
            var expectedResource = VenueGenerator.Create();

            Repository.Setup(v => v.GetByIdAsync(1)).ReturnsAsync(expectedResource);

            var viewResult = await Controller.Delete(1) as ViewResult;

            Assert.IsType <Venue>(viewResult.Model);

            var resources = viewResult.Model as Venue;

            Assert.Equal(expectedResource, resources);
        }
        public async void AddAsync_AddsToConext()
        {
            var venue = VenueGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                var repository = new VenueRepository(context);
                await repository.AddAsync(venue);

                Assert.Equal(1, await context.Venue.CountAsync());
                Assert.Equal(venue, await context.Venue.SingleAsync());
            }
        }
        public void DoesVenueExist_ChecksByName()
        {
            var venue = VenueGenerator.Create();

            venue.VenueName = "King's College";
            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                context.Venue.Add(venue);
                context.SaveChanges();
                var repository = new VenueRepository(context);
                Assert.True(repository.DoesVenueExist("King's College"));
                Assert.False(repository.DoesVenueExist("Queens's College"));
            }
        }
        public void VenueExists_ChecksById()
        {
            var venue = VenueGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                context.Venue.Add(venue);
                context.SaveChanges();
                var repository = new VenueRepository(context);
                Assert.True(repository.VenueExists(venue.VenueId));
                Assert.False(repository.VenueExists(-1));
                Console.WriteLine(venue.VenueId);
            }
        }
        public async void DeleteAsync_RemovesFromContext()
        {
            var venue = VenueGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                context.Venue.Add(venue);
                context.SaveChanges();
                Assert.Equal(1, await context.Venue.CountAsync());
                var repository = new VenueRepository(context);
                await repository.DeleteAsync(venue);

                Assert.Equal(0, await context.Venue.CountAsync());
            }
        }
        public async void UpdateAsync_UpdatesInContext()
        {
            var venue = VenueGenerator.Create();

            using (var context = new booking_facilitiesContext(contextOptions))
            {
                context.Database.EnsureCreated();
                context.Venue.Add(venue);
                context.SaveChanges();
                var repository = new VenueRepository(context);
                var newVenue   = await repository.GetByIdAsync(venue.VenueId);

                newVenue.VenueName = "Old Sports Hall";
                await repository.UpdateAsync(newVenue);

                Assert.Equal(1, await context.Venue.CountAsync());
                Assert.Equal(newVenue, await context.Venue.SingleAsync());
            }
        }