-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
4,888 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
# This file is the top-most EditorConfig file | ||
root = true | ||
|
||
# Windows-style newlines with a newline ending every file | ||
# All Files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = crlf | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = false | ||
trim_trailing_whitespace = true | ||
|
||
# .NET Code files | ||
[*.{cs,csx,cake,vb}] | ||
indent_style = tab | ||
tab_width = 4 | ||
insert_final_newline = true | ||
|
||
# Visual Studio Solution Files | ||
[*.sln] | ||
indent_style = tab | ||
tab_width = 4 | ||
|
||
# Visual Studio XML Project Files | ||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] | ||
indent_size = 2 | ||
|
||
# Various XML Configuration Files | ||
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] | ||
indent_size = 2 | ||
|
||
# JSON Files | ||
[*.{json,json5}] | ||
indent_size = 2 | ||
|
||
# YAML Files | ||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
# Markdown Files | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
# Web Files | ||
[*.{htm,html,js,ts,tsx,css,sass,scss,less,svg,vue}] | ||
indent_size = 2 | ||
insert_final_newline = true | ||
|
||
# Batch Files | ||
[*.{cmd,bat}] | ||
|
||
# Bash Files | ||
[*.sh] | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
|
||
namespace ZoomNet.IntegrationTests | ||
{ | ||
public static class ConsoleUtils | ||
{ | ||
public static void CenterConsole() | ||
{ | ||
var hWin = NativeMethods.GetConsoleWindow(); | ||
if (hWin == IntPtr.Zero) return; | ||
|
||
var monitor = NativeMethods.MonitorFromWindow(hWin, NativeMethods.MONITOR_DEFAULT_TO_NEAREST); | ||
if (monitor == IntPtr.Zero) return; | ||
|
||
var monitorInfo = new NativeMethods.NativeMonitorInfo(); | ||
NativeMethods.GetMonitorInfo(monitor, monitorInfo); | ||
|
||
NativeMethods.GetWindowRect(hWin, out NativeMethods.NativeRectangle consoleInfo); | ||
|
||
var monitorWidth = monitorInfo.Monitor.Right - monitorInfo.Monitor.Left; | ||
var monitorHeight = monitorInfo.Monitor.Bottom - monitorInfo.Monitor.Top; | ||
|
||
var consoleWidth = consoleInfo.Right - consoleInfo.Left; | ||
var consoleHeight = consoleInfo.Bottom - consoleInfo.Top; | ||
|
||
var left = monitorInfo.Monitor.Left + ((monitorWidth - consoleWidth) / 2); | ||
var top = monitorInfo.Monitor.Top + ((monitorHeight - consoleHeight) / 2); | ||
|
||
NativeMethods.MoveWindow(hWin, left, top, consoleWidth, consoleHeight, false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZoomNet.IntegrationTests | ||
{ | ||
public interface IIntegrationTest | ||
{ | ||
Task RunAsync(string userId, IClient client, TextWriter log, CancellationToken cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace ZoomNet.IntegrationTests | ||
{ | ||
public static class NativeMethods | ||
{ | ||
public const Int32 MONITOR_DEFAULT_TO_PRIMARY = 0x00000001; | ||
public const Int32 MONITOR_DEFAULT_TO_NEAREST = 0x00000002; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
public static extern IntPtr GetConsoleWindow(); | ||
|
||
[DllImport("user32.dll", SetLastError = true)] | ||
public static extern bool GetWindowRect(IntPtr hWnd, out NativeRectangle rc); | ||
|
||
[DllImport("user32.dll", SetLastError = true)] | ||
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool repaint); | ||
|
||
[DllImport("user32.dll")] | ||
public static extern IntPtr MonitorFromWindow(IntPtr handle, Int32 flags); | ||
|
||
[DllImport("user32.dll")] | ||
public static extern Boolean GetMonitorInfo(IntPtr hMonitor, NativeMonitorInfo lpmi); | ||
|
||
[Serializable, StructLayout(LayoutKind.Sequential)] | ||
public struct NativeRectangle | ||
{ | ||
public Int32 Left; | ||
public Int32 Top; | ||
public Int32 Right; | ||
public Int32 Bottom; | ||
|
||
public NativeRectangle(Int32 left, Int32 top, Int32 right, Int32 bottom) | ||
{ | ||
this.Left = left; | ||
this.Top = top; | ||
this.Right = right; | ||
this.Bottom = bottom; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] | ||
public sealed class NativeMonitorInfo | ||
{ | ||
public Int32 Size = Marshal.SizeOf(typeof(NativeMonitorInfo)); | ||
public NativeRectangle Monitor; | ||
public NativeRectangle Work; | ||
public Int32 Flags; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Logzio.DotNet.NLog; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NLog.Config; | ||
using NLog.Extensions.Logging; | ||
using NLog.Targets; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZoomNet.IntegrationTests | ||
{ | ||
public class Program | ||
{ | ||
public static async Task<int> Main(string[] args) | ||
{ | ||
var services = new ServiceCollection(); | ||
ConfigureServices(services); | ||
await using var serviceProvider = services.BuildServiceProvider(); | ||
var app = serviceProvider.GetService<TestsRunner>(); | ||
return await app.RunAsync().ConfigureAwait(false); | ||
} | ||
|
||
private static void ConfigureServices(ServiceCollection services) | ||
{ | ||
services | ||
.AddLogging(loggingBuilder => loggingBuilder.AddNLog(GetNLogConfiguration())) | ||
.AddTransient<TestsRunner>(); | ||
} | ||
|
||
private static LoggingConfiguration GetNLogConfiguration() | ||
{ | ||
// Configure logging | ||
var nLogConfig = new LoggingConfiguration(); | ||
|
||
// Send logs to logz.io | ||
var logzioToken = Environment.GetEnvironmentVariable("LOGZIO_TOKEN"); | ||
if (!string.IsNullOrEmpty(logzioToken)) | ||
{ | ||
var logzioTarget = new LogzioTarget { Token = logzioToken }; | ||
logzioTarget.ContextProperties.Add(new TargetPropertyWithContext("source", "ZoomNet_integration_tests")); | ||
logzioTarget.ContextProperties.Add(new TargetPropertyWithContext("ZoomNet-Version", ZoomNet.Client.Version)); | ||
|
||
nLogConfig.AddTarget("Logzio", logzioTarget); | ||
nLogConfig.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Fatal, "Logzio", "*"); | ||
} | ||
|
||
// Send logs to console | ||
var consoleTarget = new ColoredConsoleTarget(); | ||
nLogConfig.AddTarget("ColoredConsole", consoleTarget); | ||
nLogConfig.AddRule(NLog.LogLevel.Warn, NLog.LogLevel.Fatal, "ColoredConsole", "*"); | ||
|
||
return nLogConfig; | ||
} | ||
} | ||
} |
Oops, something went wrong.