public override bool Equals(object obj) { ReviewedBook other = obj as ReviewedBook; if (other == null) { return(false); } return(base.Equals(other) && this.Rating == other.Rating); }
public void CanIndexAndRetrieveModelWithExtraProperties() { Run(() => { SearchServiceClient serviceClient = Data.GetSearchServiceClient(); Index index = Book.DefineIndex(); serviceClient.Indexes.Create(index); SearchIndexClient client = Data.GetSearchIndexClient(index.Name); var resolver = new MyCustomContractResolver(); client.SerializationSettings.ContractResolver = resolver; client.DeserializationSettings.ContractResolver = resolver; string bookJson = @"{ ""ISBN"": ""123"", ""Title"": ""The Hobbit"", ""Author"": ""J.R.R.Tolkien"", ""Rating"": 5 }"; // Real customers would just use JsonConvert, but that would break the test. var expectedBook = SafeJsonConvert.DeserializeObject <ReviewedBook>(bookJson); DocumentIndexResult result = client.Documents.Index(IndexBatch.Upload(new[] { expectedBook })); Assert.Equal(1, result.Results.Count); AssertIndexActionSucceeded("123", result.Results[0], 201); SearchTestUtilities.WaitForIndexing(); Assert.Equal(1, client.Documents.Count()); ReviewedBook actualBook = client.Documents.Get <ReviewedBook>(expectedBook.ISBN); Assert.Equal(0, actualBook.Rating); actualBook.Rating = 5; Assert.Equal(expectedBook, actualBook); }); }