Skip to content

Commit 6200124

Browse files
committed
resolve conflicts
2 parents 898fc2e + 77deee2 commit 6200124

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+267
-52
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,6 @@ ASALocalRun/
339339
# BeatPulse healthcheck temp database
340340
healthchecksdb
341341
*.snk
342+
343+
# Ignore user config file
344+
/src/SocketIOClient.Test/user.json
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\SocketIOClient\SocketIOClient.csproj" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace SocketIOClient.Test.Configuration
2+
{
3+
public class UserConfig
4+
{
5+
public bool RunServers { get; set; } = false;
6+
public bool StopServersAfterRun { get; set; } = false;
7+
}
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO;
2+
3+
namespace SocketIOClient.Test.Configuration
4+
{
5+
public class UserConfigManager
6+
{
7+
private const string configFileName = "user.json";
8+
9+
public bool Exists => File.Exists(configFileName);
10+
11+
public UserConfig Get()
12+
{
13+
if (!this.Exists)
14+
{
15+
return null;
16+
}
17+
18+
return System.Text.Json.JsonSerializer.Deserialize<UserConfig>(File.ReadAllText(configFileName));
19+
}
20+
}
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Rename "user_sample.json" to "user.json" and copy to output directory (comment must be removed)
2+
{
3+
"RunServers": true,
4+
"StopServersAfterRun": true
5+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
5+
namespace SocketIOClient.Test.Helpers
6+
{
7+
public static class CommandHelper
8+
{
9+
public static Process RunCommand(string fileName, string argument, string workingDirectory = null)
10+
{
11+
if (string.IsNullOrEmpty(workingDirectory))
12+
{
13+
workingDirectory = Directory.GetDirectoryRoot(Directory.GetCurrentDirectory());
14+
}
15+
16+
var processStartInfo = new ProcessStartInfo()
17+
{
18+
FileName = fileName,
19+
Arguments = argument,
20+
WorkingDirectory = workingDirectory,
21+
UseShellExecute = true,
22+
WindowStyle = ProcessWindowStyle.Minimized,
23+
};
24+
25+
var process = Process.Start(processStartInfo);
26+
27+
if (process == null)
28+
{
29+
throw new Exception("Process should not be null.");
30+
}
31+
32+
return process;
33+
}
34+
}
35+
}

src/SocketIOClient.Test/SocketIOClient.Test.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<ItemGroup>
99
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
1010
<PackageReference Include="Moq" Version="4.16.1" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.4" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.5" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.2.5" />
1313
</ItemGroup>
1414

1515
<ItemGroup>
@@ -28,6 +28,9 @@
2828
<None Update="Files\tianlongbabu.epub">
2929
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3030
</None>
31+
<None Update="user.json">
32+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
33+
</None>
3134
</ItemGroup>
3235

3336
</Project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using SocketIOClient.Test.Configuration;
3+
using SocketIOClient.Test.SocketIOTests.V4;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Threading;
7+
8+
namespace SocketIOClient.Test.SocketIOTests
9+
{
10+
[TestClass]
11+
12+
public class AssemblyIntegrationTest
13+
{
14+
private static readonly IEnumerable<IServerManager> Servers = new List<IServerManager>()
15+
{
16+
new ServerV2Manager(),
17+
new ServerV3Manager(),
18+
new ServerV4Manager()
19+
};
20+
21+
private static UserConfig UserConfig => new UserConfigManager().Get() ?? new UserConfig();
22+
23+
private static bool IsRunningOnAzureDevOps => Environment.GetEnvironmentVariable("SYSTEM_DEFINITIONID") != null;
24+
25+
[AssemblyInitialize]
26+
public static void Initialize(TestContext context)
27+
{
28+
if (!IsRunningOnAzureDevOps && UserConfig.RunServers)
29+
{
30+
foreach (var server in Servers)
31+
{
32+
server.Create();
33+
}
34+
35+
// Give some time to be sure that servers are running.
36+
Thread.Sleep(5000);
37+
}
38+
}
39+
40+
[AssemblyCleanup]
41+
public static void Cleanup()
42+
{
43+
if (!IsRunningOnAzureDevOps && UserConfig.RunServers && UserConfig.StopServersAfterRun)
44+
{
45+
foreach (var server in Servers)
46+
{
47+
server.Destroy();
48+
}
49+
}
50+
}
51+
}
52+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using SocketIOClient.Test.Helpers;
2+
using System.Diagnostics;
3+
using System.IO;
4+
5+
namespace SocketIOClient.Test.SocketIOTests
6+
{
7+
public class BaseServerManager
8+
{
9+
private readonly string directory;
10+
private Process nodeProcess;
11+
12+
public BaseServerManager(string directory)
13+
{
14+
this.directory = directory;
15+
}
16+
17+
public void Create()
18+
{
19+
var workingDirectory = Path.GetFullPath(directory);
20+
var npmInstallProcess = CommandHelper.RunCommand("npm", "install", workingDirectory);
21+
22+
// We wait until the installation process is finished (or we get a timeout).
23+
if (!npmInstallProcess.WaitForExit(60000))
24+
{
25+
throw new System.SystemException("Failed restoring packages of server");
26+
}
27+
28+
// Time to run the node server.
29+
this.nodeProcess = CommandHelper.RunCommand("node", "app.js", workingDirectory);
30+
}
31+
32+
public void Destroy()
33+
{
34+
nodeProcess?.Kill();
35+
}
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace SocketIOClient.Test.SocketIOTests
2+
{
3+
public interface IServerManager
4+
{
5+
public void Create();
6+
public void Destroy();
7+
}
8+
}

0 commit comments

Comments
 (0)