Skip to content

Commit

Permalink
Merge pull request #4 from Azure-Samples/proj-struct-refactoring
Browse files Browse the repository at this point in the history
Refactor helpers into a separate common project, refactor test project
  • Loading branch information
bleroy authored Aug 5, 2019
2 parents d1e20d1 + f2f785c commit f41fdd1
Show file tree
Hide file tree
Showing 26 changed files with 668 additions and 390 deletions.
12 changes: 12 additions & 0 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2"/>
</ItemGroup>

</Project>
File renamed without changes.
5 changes: 4 additions & 1 deletion WebAPISkillHelper.cs → Common/WebAPISkillHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace AzureCognitiveSearch.PowerSkills.Common
{
public static class WebApiSkillHelpers
{
public static bool TestMode = false;
public static Func<HttpRequestMessage, HttpResponseMessage> TestWww;

public static IEnumerable<WebApiRequestRecord> GetRequestRecords(HttpRequest req)
{
string jsonRequest = new StreamReader(req.Body).ReadToEnd();
Expand Down Expand Up @@ -96,7 +99,7 @@ public static async Task<IEnumerable<T>> FetchAsync<T>(
}
request.Headers.Add(apiKeyHeader, apiKey);

using (HttpResponseMessage response = await client.SendAsync(request))
using (HttpResponseMessage response = TestMode ? TestWww(request) : await client.SendAsync(request))
{
string responseBody = await response.Content.ReadAsStringAsync();
JObject responseObject = JObject.Parse(responseBody);
Expand Down
2 changes: 1 addition & 1 deletion Geo/GeoPointFromName/GeoPointFromName.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="../../*.cs" />
<ProjectReference Include="..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
19 changes: 11 additions & 8 deletions PowerSkills.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SampleData", "_SampleData"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomEntitySearch", "Text\CustomEntitySearch\CustomEntitySearch.csproj", "{F0B21155-829F-4B26-853B-82ECAAB18D23}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{F5F3F598-2DCA-42EA-9797-D3A3E7CFA2CB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tokenizer", "Text\Tokenizer\Tokenizer.csproj", "{54AFF776-801F-4328-9EEE-CFFCD20B5497}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomEntitySearchTest", "Tests\CustomEntitySearchTest\CustomEntitySearchTest.csproj", "{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerSkillTests", "Tests\PowerSkillTests\PowerSkillTests.csproj", "{6F3E1DE3-7C77-49ED-BF9C-1FED8B318386}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tokenizer", "Text\Tokenizer\Tokenizer.csproj", "{54AFF776-801F-4328-9EEE-CFFCD20B5497}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{30F1ECE3-0B5D-4ACF-A375-B7C3721AF654}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -91,14 +91,18 @@ Global
{F0B21155-829F-4B26-853B-82ECAAB18D23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0B21155-829F-4B26-853B-82ECAAB18D23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0B21155-829F-4B26-853B-82ECAAB18D23}.Release|Any CPU.Build.0 = Release|Any CPU
{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4}.Release|Any CPU.Build.0 = Release|Any CPU
{54AFF776-801F-4328-9EEE-CFFCD20B5497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54AFF776-801F-4328-9EEE-CFFCD20B5497}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54AFF776-801F-4328-9EEE-CFFCD20B5497}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54AFF776-801F-4328-9EEE-CFFCD20B5497}.Release|Any CPU.Build.0 = Release|Any CPU
{6F3E1DE3-7C77-49ED-BF9C-1FED8B318386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F3E1DE3-7C77-49ED-BF9C-1FED8B318386}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F3E1DE3-7C77-49ED-BF9C-1FED8B318386}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F3E1DE3-7C77-49ED-BF9C-1FED8B318386}.Release|Any CPU.Build.0 = Release|Any CPU
{30F1ECE3-0B5D-4ACF-A375-B7C3721AF654}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30F1ECE3-0B5D-4ACF-A375-B7C3721AF654}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30F1ECE3-0B5D-4ACF-A375-B7C3721AF654}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30F1ECE3-0B5D-4ACF-A375-B7C3721AF654}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -112,7 +116,6 @@ Global
{0C777E2F-ABEB-4D43-8E5E-6524C2E4BD4B} = {10BE854F-F22A-4AE0-8283-688E10C76275}
{0D165CE1-66B6-47AE-ABA1-EF157C4E2884} = {10BE854F-F22A-4AE0-8283-688E10C76275}
{F0B21155-829F-4B26-853B-82ECAAB18D23} = {F98E15F9-D6BB-41CE-8B5B-84E624B86203}
{496441CA-21E9-46AE-B1D3-0F2AE2C89CD4} = {F5F3F598-2DCA-42EA-9797-D3A3E7CFA2CB}
{54AFF776-801F-4328-9EEE-CFFCD20B5497} = {F98E15F9-D6BB-41CE-8B5B-84E624B86203}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion Template/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="../../*.cs" />
<ProjectReference Include="..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
91 changes: 0 additions & 91 deletions Tests/CustomEntitySearchTest/CustomEntitySearchTest.cs

This file was deleted.

Loading

0 comments on commit f41fdd1

Please sign in to comment.