Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created November 12, 2019 07:10
Show Gist options
  • Save SunXiaoShan/5f9da977a702f93f6da93745640e2d81 to your computer and use it in GitHub Desktop.
Save SunXiaoShan/5f9da977a702f93f6da93745640e2d81 to your computer and use it in GitHub Desktop.
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