Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmihai committed Feb 3, 2017
1 parent 3ad33fc commit f60d9a3
Showing 1 changed file with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ public void Dispose()
GC.Collect();
}

[Fact]
public void MultipleForwardSlashesShouldNotGetCollapsedWhenPathLooksLikeUnixPath()
[Theory]
[InlineData(@"/bin/a//x\\c;ba://", "", true)]
[InlineData(@"/shouldNotExistAtRootLevel/a//x\\c;ba://", "", false)]
[InlineData(@"a/b//x\\c;ba://", "b/a.txt", false)]
[InlineData(@"a/b//x\\c;ba://", "a/a.txt", true)]
public void MultipleForwardSlashesShouldNotGetCollapsedWhenPathLooksLikeUnixPath(string stringLookingLikeUnixPath, string intermediateFile, bool firstPathFragmentExists)
{
string content = ObjectModelHelpers.CleanupFileContents(@"
<Project>
<PropertyGroup>
<P>/tmp/a//x\\c;ba://</P>
<P>{0}</P>
</PropertyGroup>
<ItemGroup>
<I Include=""$(p)""/>
Expand All @@ -60,26 +64,32 @@ public void MultipleForwardSlashesShouldNotGetCollapsedWhenPathLooksLikeUnixPath
</Target>
</Project>");

content = string.Format(content, stringLookingLikeUnixPath);

IDictionary<string, string> globalProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
globalProperties.Add("GP", @"/tmp/a//x\\c;ba://");
using (var testFiles = new Helpers.TestProjectWithFiles(content, new []{intermediateFile}))
{
IDictionary<string, string> globalProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
globalProperties.Add("GP", stringLookingLikeUnixPath);

Project project = new Project(XmlReader.Create(new StringReader(content)), globalProperties, null);
Project project = new Project(testFiles.ProjectFile, globalProperties, null);

MockLogger logger = new MockLogger();
bool result = project.Build(logger);
Assert.Equal(true, result);
MockLogger logger = new MockLogger();
bool result = project.Build(logger);
Assert.Equal(true, result);

var expectedString = NativeMethodsShared.IsWindows ? @"/tmp/a//x\\c;ba://" : @"/tmp/a//x//c;ba://";
var expectedString = firstPathFragmentExists
? NativeMethodsShared.IsWindows ? stringLookingLikeUnixPath : stringLookingLikeUnixPath.ToSlash()
: stringLookingLikeUnixPath;

logger.AssertLogContains($"GP[{expectedString}]");
logger.AssertLogContains($"P[{expectedString}]");
logger.AssertLogContains($"I[{expectedString}]");
logger.AssertLogContains($"T[{expectedString}]");
logger.AssertLogContains($"GP[{expectedString}]");
logger.AssertLogContains($"P[{expectedString}]");
logger.AssertLogContains($"I[{expectedString}]");
logger.AssertLogContains($"T[{expectedString}]");

Assert.Equal(expectedString, project.GetPropertyValue("GP"));
Assert.Equal(expectedString, project.GetPropertyValue("P"));
Assert.Equal(expectedString, string.Join(";", project.Items.Select(i => i.EvaluatedInclude)));
Assert.Equal(expectedString, project.GetPropertyValue("GP"));
Assert.Equal(expectedString, project.GetPropertyValue("P"));
Assert.Equal(expectedString, string.Join(";", project.Items.Select(i => i.EvaluatedInclude)));
}
}

[Fact]
Expand Down

0 comments on commit f60d9a3

Please sign in to comment.