Skip to content

Commit 9405f13

Browse files
authored
enable channel tests in netcore20 (#1154)
* enable channel tests in netcore20
1 parent 83383ad commit 9405f13

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/FileSystemTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation
22
{
3-
#if !NETCOREAPP
3+
#if !NETCOREAPP1_1
44
using System;
55
using System.IO;
66
using System.Linq;
@@ -25,7 +25,7 @@ protected static FileInfo CreatePlatformFile(string fileName, DirectoryInfo fold
2525

2626
protected static DirectoryInfo GetLocalFolder()
2727
{
28-
return new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
28+
return new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create));
2929
}
3030

3131
protected static DirectoryInfo CreatePlatformFolder(string uniqueName)

Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/PlatformFileTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation
22
{
3-
#if !NETCOREAPP
3+
#if !NETCOREAPP1_1
44
using System;
55
using System.IO;
66
using System.Security.AccessControl;
@@ -179,8 +179,10 @@ public void ThrowsIOExceptionWhenFileIsAlreadyOpen()
179179
}
180180

181181
[TestMethod]
182+
[TestCategory("WindowsOnly")]
182183
public void ThrowsUnauthorizedAccessExceptionWhenProcessHasNoRightToWriteToFile()
183184
{
185+
// Only on Windows as the APIs are not available in Linux.
184186
using (new FileAccessDenier(this.platformFile, FileSystemRights.Write))
185187
{
186188
var file = new PlatformFile(this.platformFile);

Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/PlatformFolderTest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation
22
{
3-
#if !NETCOREAPP
3+
#if !NETCOREAPP1_1
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
@@ -108,9 +108,12 @@ public void ReturnsEnumerableOfObjectsRepresentingExistingFiles()
108108
}
109109

110110
[TestMethod]
111+
[TestCategory("WindowsOnly")]
111112
public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToListDirectory()
112113
{
113114
Trace.WriteLine(string.Format("{0} Blocking Listing Permission on: {1} ",DateTime.Now.ToLongTimeString(), this.storageFolder.FullName));
115+
// Only on Windows as the APIs are not available in Linux.
116+
// The product also does not this this.
114117
using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.ListDirectory))
115118
{
116119
var folder = new PlatformFolder(this.storageFolder);
@@ -176,10 +179,13 @@ public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong()
176179
AssertEx.Throws<PathTooLongException>(() => folder.CreateFile(new string('F', 1024)));
177180
}
178181

179-
[TestMethod]
182+
[TestMethod]
183+
[TestCategory("WindowsOnly")]
180184
public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToCreateFile()
181185
{
182186
Trace.WriteLine(string.Format("{0} Blocking Listing Permission on: {1} ", DateTime.Now.ToLongTimeString(), this.storageFolder.FullName));
187+
// Only on Windows as the APIs are not available in Linux.
188+
// The product also does not this this.
183189
using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.CreateFiles))
184190
{
185191
var folder = new PlatformFolder(this.storageFolder);

0 commit comments

Comments
 (0)