Skip to content

Commit

Permalink
fix test to work on non windows OS's
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Nov 24, 2023
1 parent 3993b9f commit 7babfef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/EditorConfig.Tests/InMemory/InMemoryConfigTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using EditorConfig.Core;
using FluentAssertions;
using Microsoft.VisualBasic;
using NUnit.Framework;

namespace EditorConfig.Tests.InMemory
Expand Down Expand Up @@ -30,22 +31,27 @@ public void InMemoryConfigIsUsable()
[Test]
public void InMemoryConfigIsUsableWithVirtualPath()
{
var virtualDirectory = Path.Combine(Directory.GetDirectoryRoot("."), "VirtualPath");

var configContent = @"""
root = true
[*.cs]
end_of_line = lf
""";
var stringReader = new StringReader(configContent);
var editorConfigFile = EditorConfigFile.Parse(stringReader, "C://VirtualPath");
var editorConfigFile = EditorConfigFile.Parse(stringReader, virtualDirectory);

var parser = new EditorConfigParser();

var config1 = parser.Parse("C://VirtualPath/myfile.cs", new[] { editorConfigFile });
var file = Path.Combine(virtualDirectory, "myfile.cs");
var config1 = parser.Parse(file, new[] { editorConfigFile });
config1.EditorConfigFiles.Should().ContainSingle(f => f.IsRoot);
config1.EndOfLine.Should().Be(EndOfLine.LF);

var config2 = parser.Parse("C://DifferentFolder/myfile.cs", new[] { editorConfigFile });
var directoryOutOfScope = Path.Combine(Directory.GetDirectoryRoot("."), "DifferentDirectory");
var fileOutOfScope = Path.Combine(directoryOutOfScope, "myfile.cs");
var config2 = parser.Parse(fileOutOfScope, new[] { editorConfigFile });
config2.EditorConfigFiles.Should().BeEmpty();
}
}
Expand Down

0 comments on commit 7babfef

Please sign in to comment.