Exemple #1
0
        public async Task WhenINavigateToDiscovery_ThenIShouldLandOnTheDiscoveryPage()
        {
            // Arrange
            var _sut = new SpotkickController(
                It.IsAny <SpotifyService>(),
                It.IsAny <ArtistService>(),
                mockGetUserAsyncInUserManager(),
                It.IsAny <SignInManager <User> >());

            // Act
            var result = _sut.Discovery() as ViewResult;

            // Assert
            ((User)result?.ViewData["User"])?.ShouldBe(testUser);
        }
Exemple #2
0
        WhenIHaveCompletedSpotifyLoginAndGrantedPermissions_ThenIShouldBeRedirectedToTheDiscoveryPage()
        {
            // Arrange
            var _sut = new SpotkickController(
                mockAuthorizeUserInSpotifyService(),
                It.IsAny <ArtistService>(),
                mockGetUserAsyncInUserManager(),
                mockSignInAsyncInSignInManager());

            // Act
            var result = await _sut.Callback("auth_code_string_provided_by_spotify");

            // Assert
            result.ShouldBeOfType <RedirectResult>();
            result.Url.ShouldBe("Discovery");
        }
Exemple #3
0
        public async Task WhenINavigateToTheSSOPage_ThenIShouldBeRedirectedToSpotifyToLogin()
        {
            // Arrange
            var _sut = new SpotkickController(
                mockAuthorizeUrlInSpotifyService(),
                It.IsAny <ArtistService>(),
                It.IsAny <UserManager <User> >(),
                It.IsAny <SignInManager <User> >());

            // Act
            var result = _sut.Sso();

            // Assert
            result?.ShouldBeOfType <RedirectResult>();
            result?.Url.ShouldContain("/authorize?scope=");
        }
Exemple #4
0
        public async Task WhenINavigateToIndex_ThenIShouldLandOnTheHomePage()
        {
            // Arrange
            var _sut = new SpotkickController(
                It.IsAny <SpotifyService>(),
                It.IsAny <ArtistService>(),
                It.IsAny <UserManager <User> >(),
                It.IsAny <SignInManager <User> >());

            // Act
            var result = _sut.Index() as ViewResult;

            // Assert
            // default view for controller method always has ViewName of null
            result?.ViewName.ShouldBe(null);
        }
Exemple #5
0
        public async Task WhenIHaveSelectedSomeArtistsAndProceedToCreateAPlaylist_ThenIShouldLandOnThePlaylistPage()
        {
            // Arrange
            var _sut = new SpotkickController(
                mockGetMostPopularTracksAndCreatePlaylistInSpotifyService(),
                mockGetArtistsByIdInArtistService(),
                mockGetUserAsyncInUserManager(),
                It.IsAny <SignInManager <User> >());

            // Act
            var result = await _sut.Playlist(new List <long>(), 1) as ViewResult;

            // Assert
            result?.Model.ShouldBeOfType <PlaylistViewModel>();
            // default view for controller method always has ViewName of null
            result?.ViewName.ShouldBe(null);
        }
Exemple #6
0
        public async Task WhenINavigateToSelection_ThenIShouldLandOnThePlaylistPage()
        {
            // Arrange
            const string city = "New York";
            var          _sut = new SpotkickController(
                mockGetFollowedArtistsInSpotifyService(),
                mockGetArtistsWithEventsUsingAreaCalendarInArtistService(),
                mockGetUserAsyncInUserManager(),
                It.IsAny <SignInManager <User> >());

            // Act
            var result = await _sut.Selection(city) as ViewResult;

            // Assert
            result?.Model.ShouldBeOfType <SelectionViewModel>();
            // default view for controller method always has ViewName of null
            result?.ViewName.ShouldBe(null);

            var model = result?.Model as SelectionViewModel;

            model?.Location.City.ShouldBe(city);
            model?.User.Id.ShouldBe(testUser.Id);
            model?.Artists.ShouldBe(testArtistsList);
        }