Beispiel #1
0
        public async Task DeleteConfirmed_ShouldDeleteConferenceFromDataStoreAndRedirectToIndexView()
        {
            // Arrange
            var conferencesIndexViewModel   = A.Fake <IConferencesIndexViewModel>();
            var conferencesDetailsViewModel = A.Fake <IConferencesDetailsViewModel>();
            var conferenceRepository        = A.Fake <IConferenceRepository>();
            var sharedRepository            = A.Fake <ISharedRepository>();
            var testController = new ConferencesController(conferencesIndexViewModel, conferencesDetailsViewModel,
                                                           conferenceRepository, sharedRepository);

            int id = 1;

            // Act
            var result = await testController.DeleteConfirmed(id);

            // Assert
            A.CallTo(() => conferenceRepository.DeleteAsync(id)).MustHaveHappenedOnceExactly();
            A.CallTo(() => sharedRepository.SaveChangesAsync()).MustHaveHappenedOnceExactly();
            result.ShouldBeOfType <RedirectToActionResult>();
            ((RedirectToActionResult)result).ActionName.ShouldBe <string>(nameof(testController.Index));
        }