// Copyright 2017-2018 Alexander Luzgarev using System.IO; namespace MatFileHandler.Tests { /// /// A filename convention based on file extensions. /// internal class ExtensionTestFilenameConvention : ITestFilenameConvention { /// /// Initializes a new instance of the class. /// /// File extension. public ExtensionTestFilenameConvention(string extension) { Extension = extension; } private string Extension { get; } /// /// Convert test name to filename by adding the extension. /// /// Test name. /// The corresponding filename. public string ConvertTestNameToFilename(string testName) { return Path.ChangeExtension(testName, Extension); } /// /// Compare file's extension to the one specified during initialization. /// /// Filename. /// True iff the file has the extension stored in the class. public bool FilterFile(string filename) { return Path.GetExtension(filename) == "." + Extension; } } }