Exemple #1
0
        public async Task Index_ShouldReturnConferencesIndexView()
        {
            // Arrange
            var conferencesIndexViewModel   = A.Fake <IConferencesIndexViewModel>();
            var conferencesDetailsViewModel = A.Fake <IConferencesDetailsViewModel>();

            var conferenceRepository = A.Fake <IConferenceRepository>();
            var conferences          = new List <Conference>();

            A.CallTo(() => conferenceRepository.GetConferencesAsync()).Returns(conferences);

            var sharedRepository = A.Fake <ISharedRepository>();
            var testController   = new ConferencesController(conferencesIndexViewModel, conferencesDetailsViewModel,
                                                             conferenceRepository, sharedRepository);

            // Act
            var result = await testController.Index();

            // Assert
            A.CallTo(() => conferenceRepository.GetConferencesAsync()).MustHaveHappenedOnceExactly();
            conferencesIndexViewModel.Conferences.ShouldBe(conferences);
            result.ShouldBeOfType <ViewResult>();
            ((ViewResult)result).Model.ShouldBe(conferencesIndexViewModel);
        }