コード例 #1
0
		public void Can_deserialize_empty_type()
		{
			var ssModel = JsonSerializer.DeserializeFromString<Movie>("{}");
			var ssDynamicModel = JsonSerializer.DeserializeFromString("{}", typeof(Movie));
			var bclModel = BclJsonDataContractDeserializer.Instance.Parse<Movie>("{}");

			var defaultModel = new Movie();
			Assert.That(ssModel, Is.EqualTo(defaultModel));
			Assert.That(ssModel, Is.EqualTo(ssDynamicModel));

			//It's equal except that the BCL resets Lists/Arrays to null which is stupid
			bclModel.Genres = new List<string>();
			Assert.That(ssModel, Is.EqualTo(bclModel));
		}
コード例 #2
0
		public void Can_Write_QueryString()
		{
			var newMovie = new Movie
			{
				Id = "tt0110912",
				Title = "Pulp Fiction",
				Rating = 8.9m,
				Director = "Quentin Tarantino",
				ReleaseDate = new DateTime(1994, 10, 24),
				TagLine = "Girls like me don't make invitations like this to just anyone!",
				Genres = new List<string> { "Crime", "Drama", "Thriller" },
			};

			var queryString = QueryStringSerializer.SerializeToString(newMovie);

			Console.WriteLine(queryString);
		}
コード例 #3
0
		public void Can_Write_QueryString()
		{
            Movie newMovie = new Movie
            {
                Id = "tt0110912",
                Title = "Pulp Fiction",
                Rating = 8.9m,
                Director = "Quentin Tarantino",
                ReleaseDate = new DateTime(1994, 10, 24),
                TagLine = "Girls like me don't make invitations like this to just anyone!",
                Genres = new List<string> { "Crime", "Drama", "Thriller" },
            };

            var queryString = QueryStringSerializer.SerializeToString(newMovie);

			queryString.Print();
        
            Assert.That(queryString,
                Is.EqualTo("Id=tt0110912&Title=Pulp+Fiction&Rating=8.9&Director=Quentin+Tarantino&ReleaseDate=1994-10-24&TagLine=Girls+like+me+don%27t+make+invitations+like+this+to+just+anyone%21&Genres=Crime,Drama,Thriller"));
        }
コード例 #4
0
 public bool Equals(Movie other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Id, Id) && Equals(other.Title, Title) && other.Rating == Rating && Equals(other.Director, Director) && other.ReleaseDate.Equals(ReleaseDate) && Equals(other.TagLine, TagLine) && Genres.EquivalentTo(other.Genres);
 }
コード例 #5
0
		public bool Equals(Movie other)
        {
            return !object.ReferenceEquals(null, other) && (object.ReferenceEquals(this, other) || (object.Equals(other.Id, this.Id) && object.Equals(other.Title, this.Title) && other.Rating == this.Rating && object.Equals(other.Director, this.Director) && other.ReleaseDate.Equals(this.ReleaseDate) && object.Equals(other.TagLine, this.TagLine) && EnumerableExtensions.EquivalentTo<string>(this.Genres, other.Genres)));
        }