Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 155 additions & 34 deletions src/Search/Search.Tests/Search.Tests.csproj

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

161 changes: 161 additions & 0 deletions src/Search/Search.Tests/Tests/GetSearchTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using Microsoft.Azure.Test.TestCategories;
using Xunit;

namespace Microsoft.Azure.Search.Tests
{
public class GetSearchTests : SearchTests
{
[Fact]
public void CanSearchStaticallyTypedDocuments()
{
Run(TestCanSearchStaticallyTypedDocuments);
}

[Fact]
public void CanSearchDynamicDocuments()
{
Run(TestCanSearchDynamicDocuments);
}

[Fact]
public void SearchThrowsWhenRequestIsMalformed()
{
Run(TestSearchThrowsWhenRequestIsMalformed);
}

[Fact]
public void DefaultSearchModeIsAny()
{
Run(TestDefaultSearchModeIsAny);
}

[Fact]
public void CanSearchWithSearchModeAll()
{
Run(TestCanSearchWithSearchModeAll);
}

[Fact]
public void CanGetResultCountInSearch()
{
Run(TestCanGetResultCountInSearch);
}

[Fact]
public void CanFilter()
{
Run(TestCanFilter);
}

[Fact]
public void CanUseHitHighlighting()
{
Run(TestCanUseHitHighlighting);
}

[Fact]
public void OrderByProgressivelyBreaksTies()
{
Run(TestOrderByProgressivelyBreaksTies);
}

[Fact]
public void SearchWithoutOrderBySortsByScore()
{
Run(TestSearchWithoutOrderBySortsByScore);
}

[Fact]
public void CanSearchWithSelectedFields()
{
Run(TestCanSearchWithSelectedFields);
}

[Fact]
public void CanUseTopAndSkipForClientSidePaging()
{
Run(TestCanUseTopAndSkipForClientSidePaging);
}

[Fact]
public void SearchWithScoringProfileBoostsScore()
{
Run(TestSearchWithScoringProfileBoostsScore);
}

[Fact]
public void CanSearchWithRangeFacets()
{
Run(TestCanSearchWithRangeFacets);
}

[Fact]
public void CanSearchWithValueFacets()
{
Run(TestCanSearchWithValueFacets);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanContinueSearchForStaticallyTypedDocuments()
{
Run(TestCanContinueSearchForStaticallyTypedDocuments);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanContinueSearchForDynamicDocuments()
{
Run(TestCanContinueSearchForDynamicDocuments);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanContinueSearchWithoutTop()
{
Run(TestCanContinueSearchWithoutTop);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanSearchWithMinimumCoverage()
{
Run(TestCanSearchWithMinimumCoverage);
}

[Fact]
public void CanSearchWithDateTimeInStaticModel()
{
Run(TestCanSearchWithDateTimeInStaticModel);
}

protected override SearchIndexClient GetClient()
{
SearchIndexClient client = base.GetClient();
client.UseHttpGetForQueries = true;
return client;
}

protected override SearchIndexClient GetClientForQuery()
{
SearchIndexClient client = base.GetClientForQuery();
client.UseHttpGetForQueries = true;
return client;
}
}
}
124 changes: 124 additions & 0 deletions src/Search/Search.Tests/Tests/GetSuggestTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using Microsoft.Azure.Test.TestCategories;
using Xunit;

namespace Microsoft.Azure.Search.Tests
{
public class GetSuggestTests : SuggestTests
{
[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanSuggestStaticallyTypedDocuments()
{
Run(TestCanSuggestStaticallyTypedDocuments);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanSuggestDynamicDocuments()
{
Run(TestCanSuggestDynamicDocuments);
}

[Fact]
public void SuggestThrowsWhenRequestIsMalformed()
{
Run(TestSuggestThrowsWhenRequestIsMalformed);
}

[Fact]
public void SuggestThrowsWhenGivenBadSuggesterName()
{
Run(TestSuggestThrowsWhenGivenBadSuggesterName);
}

[Fact]
public void FuzzyIsOffByDefault()
{
Run(TestFuzzyIsOffByDefault);
}

[Fact]
public void CanGetFuzzySuggestions()
{
Run(TestCanGetFuzzySuggestions);
}

[Fact]
public void CanFilter()
{
Run(TestCanFilter);
}

[Fact]
public void CanUseHitHighlighting()
{
Run(TestCanUseHitHighlighting);
}

[Fact]
public void OrderByProgressivelyBreaksTies()
{
Run(TestOrderByProgressivelyBreaksTies);
}

[Fact]
public void TopTrimsResults()
{
Run(TestTopTrimsResults);
}

[Fact]
public void CanSuggestWithSelectedFields()
{
Run(TestCanSuggestWithSelectedFields);
}

[Fact]
public void SearchFieldsExcludesFieldsFromSuggest()
{
Run(TestSearchFieldsExcludesFieldsFromSuggest);
}

[Fact]
[Trait(TestTraits.AcceptanceType, TestTraits.LiveBVT)]
public void CanSuggestWithMinimumCoverage()
{
Run(TestCanSuggestWithMinimumCoverage);
}

[Fact]
public void CanSuggestWithDateTimeInStaticModel()
{
Run(TestCanSuggestWithDateTimeInStaticModel);
}

protected override SearchIndexClient GetClient()
{
SearchIndexClient client = base.GetClient();
client.UseHttpGetForQueries = true;
return client;
}

protected override SearchIndexClient GetClientForQuery()
{
SearchIndexClient client = base.GetClientForQuery();
client.UseHttpGetForQueries = true;
return client;
}
}
}
24 changes: 8 additions & 16 deletions src/Search/Search.Tests/Tests/IndexingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,29 +276,25 @@ public void StaticallyTypedDateTimesRoundTripAsUtc()

SearchIndexClient indexClient = Data.GetSearchIndexClient(createIndexResponse.Index.Name);

DateTime localDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Local);
// Can't test local date time since we might be testing against a pre-recorded mock response.
DateTime utcDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime unspecifiedDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);

var batch =
IndexBatch.Create(
new[]
{
IndexAction.Create(new Book() { ISBN = "1", PublishDate = localDateTime }),
IndexAction.Create(new Book() { ISBN = "2", PublishDate = utcDateTime }),
IndexAction.Create(new Book() { ISBN = "3", PublishDate = unspecifiedDateTime })
IndexAction.Create(new Book() { ISBN = "1", PublishDate = utcDateTime }),
IndexAction.Create(new Book() { ISBN = "2", PublishDate = unspecifiedDateTime })
});

indexClient.Documents.Index(batch);
SearchTestUtilities.WaitForIndexing();

DocumentGetResponse<Book> getResponse = indexClient.Documents.Get<Book>("1");
Assert.Equal(localDateTime.ToUniversalTime(), getResponse.Document.PublishDate);

getResponse = indexClient.Documents.Get<Book>("2");
Assert.Equal(utcDateTime, getResponse.Document.PublishDate);

getResponse = indexClient.Documents.Get<Book>("3");
getResponse = indexClient.Documents.Get<Book>("2");
Assert.Equal(utcDateTime, getResponse.Document.PublishDate);
});
}
Expand Down Expand Up @@ -326,29 +322,25 @@ public void DynamicDocumentDateTimesRoundTripAsUtc()

SearchIndexClient indexClient = Data.GetSearchIndexClient(createIndexResponse.Index.Name);

DateTime localDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Local);
// Can't test local date time since we might be testing against a pre-recorded mock response.
DateTime utcDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime unspecifiedDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);

var batch =
new IndexBatch(
new[]
{
new IndexAction(new Document() { { "ISBN", "1" }, { "PublishDate", localDateTime } }),
new IndexAction(new Document() { { "ISBN", "2" }, { "PublishDate", utcDateTime } }),
new IndexAction(new Document() { { "ISBN", "3" }, { "PublishDate", unspecifiedDateTime } })
new IndexAction(new Document() { { "ISBN", "1" }, { "PublishDate", utcDateTime } }),
new IndexAction(new Document() { { "ISBN", "2" }, { "PublishDate", unspecifiedDateTime } })
});

indexClient.Documents.Index(batch);
SearchTestUtilities.WaitForIndexing();

DocumentGetResponse getResponse = indexClient.Documents.Get("1");
Assert.Equal(new DateTimeOffset(localDateTime), getResponse.Document["PublishDate"]);

getResponse = indexClient.Documents.Get("2");
Assert.Equal(new DateTimeOffset(utcDateTime), getResponse.Document["PublishDate"]);

getResponse = indexClient.Documents.Get("3");
getResponse = indexClient.Documents.Get("2");
Assert.Equal(new DateTimeOffset(utcDateTime), getResponse.Document["PublishDate"]);
});
}
Expand Down
13 changes: 11 additions & 2 deletions src/Search/Search.Tests/Tests/Models/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public override bool Equals(object obj)
return false;
}

return ISBN == other.ISBN && Title == other.Title && Author == other.Author;
return
ISBN == other.ISBN &&
Title == other.Title &&
Author == other.Author &&
PublishDate == other.PublishDate;
}

public override int GetHashCode()
Expand All @@ -46,7 +50,12 @@ public override int GetHashCode()

public override string ToString()
{
return string.Format("ISBN: {0}; Title: {1}; Author: {2}", ISBN, Title, Author);
return string.Format(
"ISBN: {0}; Title: {1}; Author: {2}; PublishDate: {3}",
ISBN,
Title,
Author,
PublishDate);
}
}
}
Loading