public override bool Equals(object obj) { NonNullableModel other = obj as NonNullableModel; if (other == null) { return(false); } return (this.Count == other.Count && this.EndDate == other.EndDate && this.IsEnabled == other.IsEnabled && this.Key == other.Key && this.Rating == other.Rating && this.Ratio == other.Ratio && this.StartDate == other.StartDate); }
protected void TestCanRoundTripNonNullableValueTypes() { SearchServiceClient serviceClient = Data.GetSearchServiceClient(); var index = new Index() { Name = SearchTestUtilities.GenerateName(), Fields = FieldBuilder.BuildForType <NonNullableModel>() }; serviceClient.Indexes.Create(index); SearchIndexClient indexClient = Data.GetSearchIndexClient(index.Name); var startDate = new DateTimeOffset(2015, 11, 24, 14, 01, 00, TimeSpan.FromHours(-8)); DateTime endDate = startDate.UtcDateTime + TimeSpan.FromDays(15); var doc1 = new NonNullableModel() { Key = "123", Count = 3, EndDate = endDate, IsEnabled = true, Rating = 5, Ratio = 3.14, StartDate = startDate, TopLevelBucket = new Bucket() { BucketName = "A", Count = 12 }, Buckets = new[] { new Bucket() { BucketName = "B", Count = 20 }, new Bucket() { BucketName = "C", Count = 7 } } }; var doc2 = new NonNullableModel() { Key = "456", Count = default(long), EndDate = default(DateTime), IsEnabled = default(bool), Rating = default(int), Ratio = default(double), StartDate = default(DateTimeOffset), TopLevelBucket = default(Bucket), Buckets = new[] { default(Bucket) } }; var batch = IndexBatch.Upload(new[] { doc1, doc2 }); indexClient.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentSearchResult <NonNullableModel> response = indexClient.Documents.Search <NonNullableModel>("*"); Assert.Equal(2, response.Results.Count); Assert.Equal(doc1, response.Results[0].Document); Assert.Equal(doc2, response.Results[1].Document); }
protected void TestCanRoundTripNonNullableValueTypes() { SearchServiceClient serviceClient = Data.GetSearchServiceClient(); Index index = new Index() { Name = SearchTestUtilities.GenerateName(), Fields = new[] { new Field("Key", DataType.String) { IsKey = true }, new Field("Rating", DataType.Int32), new Field("Count", DataType.Int64), new Field("IsEnabled", DataType.Boolean), new Field("Ratio", DataType.Double), new Field("StartDate", DataType.DateTimeOffset), new Field("EndDate", DataType.DateTimeOffset) } }; serviceClient.Indexes.Create(index); SearchIndexClient indexClient = Data.GetSearchIndexClient(index.Name); DateTimeOffset startDate = new DateTimeOffset(2015, 11, 24, 14, 01, 00, TimeSpan.FromHours(-8)); DateTime endDate = startDate.UtcDateTime + TimeSpan.FromDays(15); var doc1 = new NonNullableModel() { Key = "123", Count = 3, EndDate = endDate, IsEnabled = true, Rating = 5, Ratio = 3.14, StartDate = startDate }; var doc2 = new NonNullableModel() { Key = "456", Count = default(long), EndDate = default(DateTime), IsEnabled = default(bool), Rating = default(int), Ratio = default(double), StartDate = default(DateTimeOffset) }; var batch = IndexBatch.Upload(new[] { doc1, doc2 }); indexClient.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentSearchResult <NonNullableModel> response = indexClient.Documents.Search <NonNullableModel>("*"); Assert.Equal(2, response.Results.Count); Assert.Equal(doc1, response.Results[0].Document); Assert.Equal(doc2, response.Results[1].Document); }