This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/configurable_loglevel' into develop
- Loading branch information
Showing
25 changed files
with
431 additions
and
238 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
32 changes: 32 additions & 0 deletions
32
Source/CakeMail.RestClient.IntegrationTests/ConsoleUtils.cs
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 CakeMail.RestClient.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); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Source/CakeMail.RestClient.IntegrationTests/IIntegrationTest.cs
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 CakeMail.RestClient.IntegrationTests | ||
{ | ||
public interface IIntegrationTest | ||
{ | ||
Task Execute(ICakeMailRestClient client, string userKey, long clientId, TextWriter log, CancellationToken cancellationToken); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Source/CakeMail.RestClient.IntegrationTests/NativeMethods.cs
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 CakeMail.RestClient.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
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
Oops, something went wrong.