Skip to content

Commit 2723df8

Browse files
committed
Merge branch 'enable-storage-emul-tests' into dev
2 parents 3360432 + 2b2fa3c commit 2723df8

File tree

2 files changed

+80
-28
lines changed

2 files changed

+80
-28
lines changed

test/Serilog.Sinks.AzureTableStorageWithProperties.Tests/AzureStorageEmulatorManager.cs

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,42 @@ namespace Serilog.Sinks.AzureTableStorage.Tests
1212
public static class AzureStorageEmulatorManager
1313
{
1414
private const string _windowsAzureStorageEmulatorPath = @"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\WAStorageEmulator.exe";
15-
private const string _win7ProcessName = "WAStorageEmulator";
15+
16+
private const string _win7ProcessName = "WAStorageEmulator";
1617
private const string _win8ProcessName = "WASTOR~1";
1718

18-
private static readonly ProcessStartInfo startStorageEmulator = new ProcessStartInfo
19-
{
20-
FileName = _windowsAzureStorageEmulatorPath,
21-
Arguments = "start",
22-
};
19+
private const string _azureStorageEmulator4_4Path = @"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe";
20+
private const string _processName4_4 = "AzureStorageEmulator";
21+
22+
private static readonly ProcessStartInfo startStorageEmulator = new ProcessStartInfo
23+
{
24+
FileName = _windowsAzureStorageEmulatorPath,
25+
Arguments = "start",
26+
};
2327

24-
private static readonly ProcessStartInfo stopStorageEmulator = new ProcessStartInfo
28+
private static readonly ProcessStartInfo startStorageEmulator4_4 = new ProcessStartInfo
29+
{
30+
FileName = _azureStorageEmulator4_4Path,
31+
Arguments = "start",
32+
};
33+
34+
private static readonly ProcessStartInfo stopStorageEmulator = new ProcessStartInfo
2535
{
2636
FileName = _windowsAzureStorageEmulatorPath,
2737
Arguments = "stop",
2838
};
2939

30-
private static Process GetProcess()
40+
private static readonly ProcessStartInfo stopStorageEmulator4_4 = new ProcessStartInfo
41+
{
42+
FileName = _azureStorageEmulator4_4Path,
43+
Arguments = "stop",
44+
};
45+
46+
private static Process GetProcess()
3147
{
32-
return Process.GetProcessesByName(_win7ProcessName).FirstOrDefault() ?? Process.GetProcessesByName(_win8ProcessName).FirstOrDefault();
48+
return Process.GetProcessesByName(_win7ProcessName).FirstOrDefault()
49+
?? Process.GetProcessesByName(_win8ProcessName).FirstOrDefault()
50+
?? Process.GetProcessesByName(_processName4_4).FirstOrDefault();
3351
}
3452

3553
public static bool IsProcessStarted()
@@ -41,19 +59,53 @@ public static void StartStorageEmulator()
4159
{
4260
if (!IsProcessStarted())
4361
{
44-
using (Process process = Process.Start(startStorageEmulator))
45-
{
46-
process.WaitForExit();
47-
}
48-
}
62+
try
63+
{
64+
using (Process process = Process.Start(startStorageEmulator4_4))
65+
{
66+
process.WaitForExit();
67+
}
68+
}
69+
catch(System.ComponentModel.Win32Exception ex)
70+
{
71+
if (ex.Message == "The system cannot find the file specified")
72+
{
73+
using (Process process = Process.Start(startStorageEmulator))
74+
{
75+
process.WaitForExit();
76+
}
77+
}
78+
else
79+
{
80+
throw;
81+
}
82+
}
83+
}
4984
}
5085

5186
public static void StopStorageEmulator()
5287
{
53-
using (Process process = Process.Start(stopStorageEmulator))
54-
{
55-
process.WaitForExit();
56-
}
57-
}
58-
}
88+
try
89+
{
90+
using (Process process = Process.Start(stopStorageEmulator4_4))
91+
{
92+
process.WaitForExit();
93+
}
94+
}
95+
catch (System.ComponentModel.Win32Exception ex)
96+
{
97+
if (ex.Message == "The system cannot find the file specified")
98+
{
99+
using (Process process = Process.Start(stopStorageEmulator))
100+
{
101+
process.WaitForExit();
102+
}
103+
}
104+
else
105+
{
106+
throw;
107+
}
108+
}
109+
}
110+
}
59111
}

test/Serilog.Sinks.AzureTableStorageWithProperties.Tests/AzureTableStorageWithPropertiesSinkTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void Dispose()
4141
}
4242
}
4343

44-
[Fact(Skip = "Requires storage emulator")]
44+
[Fact]
4545
public void WhenALoggerWritesToTheSinkItIsRetrievableFromTheTableWithProperties()
4646
{
4747
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -74,7 +74,7 @@ public void WhenALoggerWritesToTheSinkItIsRetrievableFromTheTableWithProperties(
7474
Assert.Equal(" ", result.Properties["Space"].PropertyAsObject);
7575
}
7676

77-
[Fact(Skip = "Requires storage emulator")]
77+
[Fact]
7878
public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForScalar()
7979
{
8080
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -121,7 +121,7 @@ public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForScalar()
121121
Assert.Equal(stringValue, result.Properties["String"].StringValue);
122122
}
123123

124-
[Fact(Skip = "Requires storage emulator")]
124+
[Fact]
125125
public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForDictionary()
126126
{
127127
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -157,7 +157,7 @@ public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForDictionary()
157157
Assert.Equal("[(\"d1\": [(\"d1k1\": \"d1k1v1\"), (\"d1k2\": \"d1k2v2\"), (\"d1k3\": \"d1k3v3\")]), (\"d2\": [(\"d2k1\": \"d2k1v1\"), (\"d2k2\": \"d2k2v2\"), (\"d2k3\": \"d2k3v3\")])]", result.Properties["Dictionary"].StringValue);
158158
}
159159

160-
[Fact(Skip = "Requires storage emulator")]
160+
[Fact]
161161
public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForSequence()
162162
{
163163
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -198,7 +198,7 @@ private class Struct0
198198
public Struct2 Struct2Val { get; set; }
199199
}
200200

201-
[Fact(Skip = "Requires storage emulator")]
201+
[Fact]
202202
public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
203203
{
204204
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -235,7 +235,7 @@ public void WhenALoggerWritesToTheSinkItStoresTheCorrectTypesForStructure()
235235
Assert.Equal("Struct0 { Struct1Val: Struct1 { IntVal: 10, StringVal: \"ABCDE\" }, Struct2Val: Struct2 { DateTimeVal: 12/03/2014 17:37:12, DoubleVal: 3.14159265358979 } }", result.Properties["Struct0"].StringValue);
236236
}
237237

238-
[Fact(Skip = "Requires storage emulator")]
238+
[Fact]
239239
public void WhenABatchLoggerWritesToTheSinkItStoresAllTheEntries()
240240
{
241241
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -260,7 +260,7 @@ public void WhenABatchLoggerWritesToTheSinkItStoresAllTheEntries()
260260
Assert.Equal(10, result.Count());
261261
}
262262

263-
[Fact(Skip = "Requires storage emulator")]
263+
[Fact]
264264
public void WhenABatchLoggerWritesToTheSinkItStoresAllTheEntriesInDifferentPartitions()
265265
{
266266
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
@@ -289,7 +289,7 @@ public void WhenABatchLoggerWritesToTheSinkItStoresAllTheEntriesInDifferentParti
289289
Assert.Equal(8, result.Count());
290290
}
291291

292-
[Fact(Skip = "Requires storage emulator")]
292+
[Fact]
293293
public void WhenABatchLoggerWritesToTheSinkItStoresAllTheEntriesInLargeNumber()
294294
{
295295
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;

0 commit comments

Comments
 (0)