Skip to content

Commit f671cc6

Browse files
committed
Fix Unit, Integration and Functional Tests
1 parent a9464cc commit f671cc6

30 files changed

Lines changed: 136 additions & 84 deletions

eShopOnContainers-ServicesAndWebApps.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26730.15
4+
VisualStudioVersion = 15.0.27004.2002
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
77
EndProject

src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
<ItemGroup>
99
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="1.1.2" />
10-
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<Reference Include="StackExchange.Redis.StrongName">
14+
<HintPath>..\..\..\..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\stackexchange.redis.strongname\1.2.4\lib\netstandard1.5\StackExchange.Redis.StrongName.dll</HintPath>
15+
</Reference>
1116
</ItemGroup>
1217

1318
</Project>

src/BuildingBlocks/DataProtection/DataProtection/DataProtectionBuilderExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.AspNetCore.DataProtection.Repositories;
55
using Microsoft.Extensions.DependencyInjection;
66
using Microsoft.Extensions.Logging;
7+
using StackExchange.Redis;
78
using System;
89
using System.Linq;
910
using System.Net;
@@ -45,10 +46,11 @@ public static IDataProtectionBuilder PersistKeysToRedis(this IDataProtectionBuil
4546
throw new ArgumentException("Redis connection string may not be empty.", nameof(redisConnectionString));
4647
}
4748

48-
var ips = Dns.GetHostAddressesAsync(redisConnectionString).Result;
49+
var configuration = ConfigurationOptions.Parse(redisConnectionString, true);
50+
configuration.ResolveDns = true;
4951

5052
return builder.Use(ServiceDescriptor.Singleton<IXmlRepository>(services =>
51-
new RedisXmlRepository(ips.First().ToString(), services.GetRequiredService<ILogger<RedisXmlRepository>>())));
53+
new RedisXmlRepository(configuration, services.GetRequiredService<ILogger<RedisXmlRepository>>())));
5254
}
5355

5456
/// <summary>

src/BuildingBlocks/DataProtection/DataProtection/RedisXmlRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class RedisXmlRepository : IXmlRepository, IDisposable
6565
/// <exception cref="System.ArgumentNullException">
6666
/// Thrown if <paramref name="connectionString" /> or <paramref name="logger" /> is <see langword="null" />.
6767
/// </exception>
68-
public RedisXmlRepository(string connectionString, ILogger<RedisXmlRepository> logger)
68+
public RedisXmlRepository(ConfigurationOptions connectionString, ILogger<RedisXmlRepository> logger)
6969
: this(ConnectionMultiplexer.Connect(connectionString), logger)
7070
{
7171
}

test/Services/FunctionalTests/FunctionalTests.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
<None Remove="Services\Marketing\**" />
1919
</ItemGroup>
2020

21-
<ItemGroup>
22-
<None Remove="Services\Catalog\settings.json" />
23-
</ItemGroup>
24-
2521
<ItemGroup>
2622
<Compile Include="Services\Location\LocationsScenariosBase.cs" />
2723
<Compile Include="Services\Location\LocationsTestsStartup.cs" />
@@ -33,7 +29,10 @@
3329
</ItemGroup>
3430

3531
<ItemGroup>
36-
<Content Include="Services\Catalog\settings.json">
32+
<Content Include="Services\Basket\appsettings.json">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</Content>
35+
<Content Include="Services\Catalog\appsettings.json">
3736
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3837
</Content>
3938
<Content Include="Services\Location\appsettings.json">

test/Services/FunctionalTests/Services/Basket/BasketScenariosBase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace FunctionalTests.Services.Basket
22
{
3+
using Microsoft.AspNetCore;
34
using Microsoft.AspNetCore.Hosting;
45
using Microsoft.AspNetCore.TestHost;
6+
using Microsoft.Extensions.Configuration;
57
using System.IO;
68

79
public class BasketScenariosBase
@@ -10,10 +12,10 @@ public class BasketScenariosBase
1012

1113
public TestServer CreateServer()
1214
{
13-
var webHostBuilder = new WebHostBuilder();
14-
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory());
15+
var webHostBuilder = WebHost.CreateDefaultBuilder();
16+
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Basket");
1517
webHostBuilder.UseStartup<BasketTestsStartup>();
16-
18+
1719
return new TestServer(webHostBuilder);
1820
}
1921

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Logging": {
3+
"IncludeScopes": false,
4+
"LogLevel": {
5+
"Default": "Debug",
6+
"System": "Information",
7+
"Microsoft": "Information"
8+
}
9+
},
10+
"IdentityUrl": "http://localhost:5105",
11+
"ConnectionString": "127.0.0.1",
12+
"isTest": "true",
13+
"EventBusConnection": "localhost"
14+
}
15+
16+

test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using FunctionalTests.Middleware;
2+
using Microsoft.AspNetCore;
23
using Microsoft.AspNetCore.Hosting;
34
using Microsoft.AspNetCore.TestHost;
45
using Microsoft.eShopOnContainers.Services.Catalog.API;
6+
using Microsoft.Extensions.Configuration;
57
using System;
68
using System.Collections.Generic;
79
using System.IO;
@@ -13,10 +15,10 @@ public class CatalogScenariosBase
1315
{
1416
public TestServer CreateServer()
1517
{
16-
var webHostBuilder = new WebHostBuilder();
18+
var webHostBuilder = WebHost.CreateDefaultBuilder();
1719
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Catalog");
1820
webHostBuilder.UseStartup<Startup>();
19-
21+
2022
return new TestServer(webHostBuilder);
2123
}
2224

test/Services/FunctionalTests/Services/Catalog/settings.json renamed to test/Services/FunctionalTests/Services/Catalog/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"ExternalCatalogBaseUrl": "http://localhost:5101",
44
"IdentityUrl": "http://localhost:5105",
55
"isTest": "true",
6-
"EventBusConnection": "localhost"
6+
"EventBusConnection": "localhost",
7+
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/"
78
}

test/Services/FunctionalTests/Services/Location/LocationsScenariosBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
namespace FunctionalTests.Services.Locations
22
{
3+
using Microsoft.AspNetCore;
34
using Microsoft.AspNetCore.Hosting;
45
using Microsoft.AspNetCore.TestHost;
6+
using Microsoft.Extensions.Configuration;
57
using System;
68
using System.IO;
79

810
public class LocationsScenariosBase
911
{
1012
public TestServer CreateServer()
1113
{
12-
var webHostBuilder = new WebHostBuilder();
14+
var webHostBuilder = WebHost.CreateDefaultBuilder();
1315
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Location");
1416
webHostBuilder.UseStartup<LocationsTestsStartup>();
15-
17+
1618
return new TestServer(webHostBuilder);
1719
}
1820

0 commit comments

Comments
 (0)