Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public void ThrowsErrorOnPassingInNullCacheName()
 {
     // Act
     _loader = new FileObligationLoader(_fakeCacheManger.Object, _fakeFilePathResolver.Object, DirectoryName,
                                        string.Empty);
 }
Ejemplo n.º 6
0
 public void ThrowsErrorOnPassingInNullFilePathResolver()
 {
     // Act
     _loader = new FileObligationLoader(_fakeCacheManger.Object, null, DirectoryName, CacheName);
 }