public void ShouldThrowArgumentExceptionWhenExpressionIsInvalid()
        {
            // Arrange
            Action action = () => FieldsProvider.Get <FullPlaylist>(builder => builder.Include <object>(playlist => null));

            // Act + Assert
            action.ShouldThrow <ArgumentException>().Which.Message.Should().Be("The expression must be a member expression referencing the input parameter.");
        }
        public void ShouldReplaceIncludeWithExclude()
        {
            // Arrange + Act
            var result = FieldsProvider.Get <FullPlaylist>(builder => builder
                                                           .Include(playlist => playlist.Images[0].Height)
                                                           .Include(playlist => playlist.Tracks.Items[0].Track.Popularity)
                                                           .Include(playlist => playlist.Tracks.Items[0].Track.Name)
                                                           .Exclude(playlist => playlist.Tracks.Items[0].Track));

            // Assert
            result.Should().Be("(images(height),tracks(items(!track)))");
        }
        public void ShouldGetFields()
        {
            // Arrange + Act
            var result = FieldsProvider.Get <FullPlaylist>(builder => builder
                                                           .Exclude(playlist => playlist.Tracks.Items[0].Track.Album.Name)
                                                           .Exclude(playlist => playlist.Tracks.Items[0].Track.Album.Images)
                                                           .Exclude(playlist => playlist.Tracks.Items[0].Track.Artists[0].Id)
                                                           .Include(playlist => playlist.Name));

            // Assert
            result.Should().Be("(tracks(items(track(album(!name,images),artists(!id)))),name)");
        }
        public void ShouldReplaceExcludeWithInclude()
        {
            // Arrange + Act
            var result = FieldsProvider.Get <Playlist>(builder => builder
                                                       .Exclude(playlist => playlist.Images[0].Height)
                                                       .Exclude(playlist => ((Track)playlist.Tracks.Items[0].Track).Popularity)
                                                       .Exclude(playlist => ((Track)playlist.Tracks.Items[0].Track).IsPlayable)
                                                       .Include(playlist => ((Track)playlist.Tracks.Items[0].Track).Name));

            // Assert
            result.Should().Be("(images(!height),tracks(items(track(name))))");
        }
示例#5
0
 public Task <Page <PlaylistTrack> > GetAsync(Action <IFieldsBuilder <Page <PlaylistTrack> > > buildFields, string market, int?limit, int?offset, CancellationToken cancellationToken)
 {
     return(this.GetAsync(FieldsProvider.Get(buildFields), market, limit, offset, cancellationToken));
 }
 public Task <FullPlaylist> GetAsync(Action <IFieldsBuilder <FullPlaylist> > buildFields, string market, CancellationToken cancellationToken)
 {
     return(this.GetAsync(FieldsProvider.Get(buildFields), market, cancellationToken));
 }
 public void ShouldGetNullWhenThereIsNoExpression()
 {
     // Arrange + Act + Assert
     FieldsProvider.Get <FullPlaylist>(builder => { }).Should().BeNull();
 }
 public Task <Playlist> GetAsync(Action <IFieldsBuilder <Playlist> > buildFields, string market, CancellationToken cancellationToken)
 => this.GetAsync(FieldsProvider.Get(buildFields), market, cancellationToken);
示例#9
0
 public FieldValuesValidator()
 {
     _fields = FieldsProvider.GetFields();
     _fieldValidationRunner = new FieldValidatorRunner();
 }