post migration cleanup (#4449)
* Create tests * Basic scenario working & tested * Feature Complete * prevent build of intentionally broken test asset * Update migrate command backup * PR Feedback * Move negative test to negative test directory * Fix tests * make test output directories unique * Merge Conflict * make backup the default behavior * Pass2Fail * Remove tests' PJ dependency
This commit is contained in:
parent
a4776a2b2c
commit
5ede3b6367
14 changed files with 376 additions and 19 deletions
|
@ -30,11 +30,31 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveFile(string expectedFile)
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveFile(string expectedFile, string because = "", params object[] reasonArgs)
|
||||
{
|
||||
var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault();
|
||||
Execute.Assertion.ForCondition(file != null)
|
||||
.FailWith("Expected File {0} cannot be found in directory {1}.", expectedFile, _dirInfo.FullName);
|
||||
|
||||
Execute.Assertion
|
||||
.ForCondition(file != null)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWith($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveTextFile(string expectedFile, string expectedContents, string because = "", params object[] reasonArgs)
|
||||
{
|
||||
this.HaveFile(expectedFile, because, reasonArgs);
|
||||
|
||||
var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault();
|
||||
|
||||
var contents = File.ReadAllText(file.FullName);
|
||||
|
||||
Execute.Assertion
|
||||
.ForCondition(contents.Equals(expectedContents))
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWith($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -56,12 +76,26 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption)
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveTextFiles(IDictionary<string, string> expectedFiles, string because = "", params object[] reasonArgs)
|
||||
{
|
||||
foreach (var expectedFile in expectedFiles)
|
||||
{
|
||||
HaveTextFile(expectedFile.Key, expectedFile.Value, because, reasonArgs);
|
||||
}
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<DirectoryInfoAssertions> HaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption, string because = "", params object[] reasonArgs)
|
||||
{
|
||||
var matchingFileExists = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Any();
|
||||
Execute.Assertion.ForCondition(matchingFileExists == true)
|
||||
|
||||
Execute.Assertion
|
||||
.ForCondition(matchingFileExists == true)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWith("Expected directory {0} to contain files matching {1}, but no matching file exists.",
|
||||
_dirInfo.FullName, expectedFilesSearchPattern);
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
|
@ -108,5 +142,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
|
||||
public AndConstraint<DirectoryInfoAssertions> NotExist(string because = "", params object[] reasonArgs)
|
||||
{
|
||||
Execute.Assertion
|
||||
.ForCondition(_dirInfo.Exists == false)
|
||||
.BecauseOf(because, reasonArgs)
|
||||
.FailWith($"Expected directory {_dirInfo.FullName} to not exist, but it does.");
|
||||
|
||||
return new AndConstraint<DirectoryInfoAssertions>(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue