public void Setup() { _fakeFilePathResolver = new Mock <IFilePathResolver>(); _fakeCacheManger = new Mock <ICacheManager>(); _realCacheManger = new CacheManager(); _fakeFilePathResolver.Setup(x => x.GetWorkingDirectory()).Returns(DirectoryPath); _loader = new FileObligationLoader(_realCacheManger, _fakeFilePathResolver.Object, DirectoryName, CacheName); }
public void LoadsFromCache() { // Arrange _loader = new FileObligationLoader(_fakeCacheManger.Object, _fakeFilePathResolver.Object, DirectoryName, CacheName); _fakeCacheManger.Setup(x => x.Contains(CacheName)).Returns(true); // Act _loader.GetObligations(); //Assert _fakeCacheManger.Verify(x => x.Get(CacheName), Times.Once); _fakeCacheManger.Verify(x => x.Add(CacheName, It.IsAny <List <IObligation> >()), Times.Never); }
public ObligationManager(IObligationLoader obligationLoader, IRulesetLoader rulesetLoader) { if (obligationLoader == null) { throw new ArgumentNullException(nameof(obligationLoader)); } if (rulesetLoader == null) { throw new ArgumentNullException(nameof(rulesetLoader)); } _obligationLoader = obligationLoader; _rulesetLoader = rulesetLoader; }
public static void Setup(TestContext context) { var fakeFilePathResolver = new Mock <IFilePathResolver>(); var cacheManager = new CacheManager(); fakeFilePathResolver.Setup(x => x.GetWorkingDirectory()).Returns(DirectoryPath); _questionLoader = new FileQuestionLoader(cacheManager, fakeFilePathResolver.Object, "Questions", "FileContentValidationQuestions"); Assert.IsNotNull(_questionLoader); _rulesetLoader = new FileRulesetLoader(cacheManager, fakeFilePathResolver.Object, "Rules", "FileContentValidationRules"); Assert.IsNotNull(_rulesetLoader); _personaLoader = new FilePersonaLoader(cacheManager, fakeFilePathResolver.Object, "Personas", "FileContentValidationPersonas"); Assert.IsNotNull(_personaLoader); _obligationLoader = new FileObligationLoader(cacheManager, fakeFilePathResolver.Object, "Obligations", "FileContentValidationObligations"); Assert.IsNotNull(_obligationLoader); }
public void ThrowsErrorOnPassingInNullCacheName() { // Act _loader = new FileObligationLoader(_fakeCacheManger.Object, _fakeFilePathResolver.Object, DirectoryName, string.Empty); }
public void ThrowsErrorOnPassingInNullFilePathResolver() { // Act _loader = new FileObligationLoader(_fakeCacheManger.Object, null, DirectoryName, CacheName); }