Created
November 12, 2019 07:10
-
-
Save SunXiaoShan/5f9da977a702f93f6da93745640e2d81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogAnalyzer { | |
private IExtensionManager manager; | |
public LogAnalyzer(IExtensionManager mgr) { | |
manager = mgr; | |
} | |
public bool isValidLogFileName(string fileName) { | |
return manager.isValid(fileName); | |
} | |
} | |
public interface IExtensionManager { | |
bool isValid(string fileName); | |
} | |
[TestFixture] | |
public class LogAnalyzerTests { | |
[Test] | |
public void isValidFileName_NameSupportedExtension_ReturnsTrue() { | |
FakeExtensionManager fakeManager = new FakeExtensionManager(); | |
fakeManager.willBeValid = true; | |
LogAnalyzer log = new LogAnalyzer(fakeManager); | |
bool result = log.isValidLogFileName("short.txt"); | |
Assert.True(result); | |
} | |
} | |
internal class FakeExtensionManager : IExtensionManager { | |
public bool willBeValid = false; | |
public bool isValid(string fileName) { | |
return willBeValid; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment