I have the following test which aims to ensure that file path generated is of a specific format. Using Nunit's fluent interfaces, how can I go about this?
I am having trouble with the regex.
[Test]
public void AssetControlPath_ShouldHaveFormat_BaseDir_YYYY_MMM_YYYYMMMDD()
{
//Arrange
var baseDir = "C:\\BaseDir";
var fpBuilder = new FilePathBuilder(new DateTime(2010,10,10), baseDir );
//Act
var destinationPath = fpBuilder.AssetControlPath();
//Assert
// destinationPath = C:\BasDir\2010\Oct\20101010
Assert.That(destinationPath, Is.StringMatching(@"C:\\BaseDir\\d{4}\\[a-zA-Z]{3}\\d{8}"));
}
The unit test error
XXX.FilepathBuilderTests.AssetControlPath_ShouldHaveFormat_BaseDir_YYYY_MMM_YYYYMMMDD:
Expected: String matching "C:\\BaseDir\\d{4}\\[a-zA-Z]{3}\\d{8}"
But was: "C:\BaseDir\2010\Oct\20101010"
Edit: I have actually switched the test to use @ChrisF's approach. The question however still stands.