Beispiel #1
0
        public void GetShouldReturnOk()
        {
            var vObj = new CategoryViewModel()
            {
                Name = "Valid Name"
            };
            var dObj = new Category()
            {
                Name = "Valid Name"
            };

            _fakeCategoryService.Setup(m => m.GetCategories(It.IsAny <string>())).Returns(new List <Category>()
            {
                dObj
            });

            _fakeMapper.Setup(m => m.Map <Category, CategoryViewModel>(It.IsAny <Category>()))
            .Returns(vObj);

            var result = _sutController
                         .Calling(c => c.GetCategories())
                         .ShouldReturn()
                         .Ok()
                         .WithResponseModelOfType <List <CategoryViewModel> >()
                         .AndProvideTheModel();

            Assert.That(result, Is.Not.Empty);
        }
 public void GetOrganisationTest()
 {
     _organisationControllerWithAuthenticatedUser
     .Calling(o => o.Get(organisation.Id))
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <Organisation>()
     .Passing(o => o.Id == organisation.Id &&
              o.BannerUrl == organisation.BannerUrl &&
              o.Name == organisation.Name);
 }
Beispiel #3
0
 public void GetUserOrganisationsTest()
 {
     _userControllerWithAuthenticatedUserWithOrganisation
     .Calling(c => c.GetUserOrganisations())
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <IEnumerable <SmallOrganisationViewModel> >()
     .Passing(o => o.Count() == 1 &&
              o.First().Id == organisation.Id &&
              o.First().BannerUrl == organisation.BannerUrl &&
              o.First().Name == organisation.Name);
 }
Beispiel #4
0
 public void GetUserWithoutOrganisationOrganisationsTest()
 {
     _userControllerWithAuthenticatedUserWithoutOrganisation
     .Calling(c => c.GetUserOrganisations())
     .ShouldReturn()
     .Ok()
     .WithResponseModelOfType <IEnumerable <SmallOrganisationViewModel> >()
     .Passing(o => o.FirstOrDefault() == null);
 }
        public void GetShouldReturnMoviesFromRepoWithPaging()
        {
            var movies = Repositories.Movies.All();

            moviesController
            .Calling(x => x.GetAll())
            .ShouldReturn()
            .Ok()
            .WithResponseModelOfType <IQueryable <MovieDetailViewModel> >()
            .Passing(x =>
            {
                x.ForEach(m =>
                {
                    Assert.IsTrue(movies.Any(movie => movie.Title == m.Title));
                });

                var moviesCount = movies.Count();
                Assert.AreEqual(moviesCount > 10 ? 10 : moviesCount, x.Count());
            });
        }
Beispiel #6
0
        public void PutShouldReturnBadRequest()
        {
            var obj = new GadgetViewModel()
            {
                Name        = "Valid Name",
                Description = "Valid description",
                Price       = 1,
                Image       = "Valid Image"
            };

            _sutController
            .Calling(c => c.PutGadget(1, obj))
            .ShouldReturn()
            .BadRequest();
        }
        public void GetLivePlaylistWithNoTracksPlayedOrVoted()
        {
            List <LivePlaylistTrackViewModel> livePlaylistTracks = new List <LivePlaylistTrackViewModel>();

            foreach (var playlistTrack in playlist.PlaylistTracks)
            {
                playlistTrack.Votes = new List <Vote>();
                livePlaylistTracks.Add(new LivePlaylistTrackViewModel()
                {
                    Id            = playlistTrack.Id,
                    Track         = playlistTrack.Track,
                    Score         = 0,
                    PersonalScore = 0
                });
            }
            playlistControllerWithAuthenticatedUser
            .Calling(p => p.getLivePlaylist(playlist.Id))
            .ShouldReturn()
            .Ok()
            .WithResponseModel(new LivePlaylistViewModel()
            {
                Id                  = playlist.Id,
                PlaylistTracks      = livePlaylistTracks,
                Active              = playlist.Active,
                ChatComments        = playlist.ChatComments,
                Comments            = playlist.Comments,
                CreatedById         = playlist.CreatedById,
                Description         = playlist.Description,
                ImageUrl            = playlist.ImageUrl,
                Key                 = playlist.Key,
                MaximumVotesPerUser = playlist.MaximumVotesPerUser,
                PlaylistMasterId    = playlist.PlaylistMasterId,
                Name                = playlist.Name
            });
        }