public void DeleteConfirmed_IdNotInDb_Throws404Exception()
        {
            Mock<IVeilDataAccess> dbStub = TestHelpers.GetVeilDataAccessFake();
            Mock<DbSet<Event>> eventDbSetStub = TestHelpers.GetFakeAsyncDbSet(new List<Event>().AsQueryable());

            dbStub.Setup(db => db.Events).Returns(eventDbSetStub.Object);

            EventsController controller = new EventsController(dbStub.Object, idGetter: null);

            Assert.That(async () => await controller.DeleteConfirmed(Id), Throws.InstanceOf<HttpException>().And.Matches<HttpException>(ex => ex.GetHttpCode() == 404));
        }
        public async void DeleteConfirmed_IdInDb_CallsSaveChangesOnTheDb()
        {
            Event item = new Event
            {
                Id = Id
            };

            Mock<IVeilDataAccess> dbMock = TestHelpers.GetVeilDataAccessFake();
            Mock<DbSet<Event>> eventDbSetStub =
                TestHelpers.GetFakeAsyncDbSet(new List<Event> { item }.AsQueryable());
            eventDbSetStub.Setup(edb => edb.FindAsync(item.Id)).ReturnsAsync(item);
            eventDbSetStub.Setup(edb => edb.Remove(item)).Returns(item);

            dbMock.Setup(db => db.Events).Returns(eventDbSetStub.Object);
            dbMock.Setup(db => db.SaveChangesAsync()).ReturnsAsync(1).Verifiable();

            EventsController controller = new EventsController(dbMock.Object, idGetter: null);

            await controller.DeleteConfirmed(item.Id);

            Assert.That(
                () =>
                    dbMock.Verify(db => db.SaveChangesAsync(),
                    Times.Exactly(1)),
                Throws.Nothing);
        }
        public async void DeleteConfirmed_EmptyGuid_RedirectsToIndex()
        {
            EventsController controller = new EventsController(veilDataAccess: null, idGetter: null);

            var result = await controller.DeleteConfirmed(Guid.Empty) as RedirectToRouteResult;

            Assert.That(result != null);
            Assert.That(result.RouteValues["Action"], Is.EqualTo("Index"));
        }