Resolve() public method

Resolves the given context using all the available patterns, checking their resolution in the file system as well.
public Resolve ( IPatternResolutionContext context ) : PatternResolution
context IPatternResolutionContext Resolution context
return PatternResolution
コード例 #1
0
        public void NoMatchBecauseOfFileSystem()
        {
            var access = new Mock<IFileSystemRepositoryAccess>();
            var context = CreateContext();

            var patterns = new RepositoryPatternCollection(access.Object);
            patterns.AddPattern(new RepositoryPattern("pattern1"));
            patterns.AddPattern(new RepositoryPattern("pattern2"));
            patterns.AddPattern(new RepositoryPattern("pattern3"));

            var resolution = patterns.Resolve(context.Object);

            resolution.Should().BeNull();
        }
コード例 #2
0
        public void NoMatchBecauseOfPatternResolution()
        {
            var access = new Mock<IFileSystemRepositoryAccess>();
            var context = CreateContext();

            access.Setup(a => a.Exists(It.IsAny<string>())).Returns(true);

            var patterns = new RepositoryPatternCollection(access.Object);
            patterns.AddPattern(new RepositoryPattern("pattern1.%VERSION"));
            patterns.AddPattern(new RepositoryPattern("pattern2.%VERSION"));
            patterns.AddPattern(new RepositoryPattern("pattern3.%VERSION"));

            var resolution = patterns.Resolve(context.Object);

            resolution.Should().BeNull();
        }
コード例 #3
0
        public void FirstMatchChoosen()
        {
            var access = new Mock<IFileSystemRepositoryAccess>();
            var context = CreateContext();

            access.Setup(a => a.Exists(It.IsAny<string>())).Returns(true);

            var patterns = new RepositoryPatternCollection(access.Object);
            patterns.AddPattern(new RepositoryPattern("pattern1"));
            patterns.AddPattern(new RepositoryPattern("pattern2"));
            patterns.AddPattern(new RepositoryPattern("pattern3"));

            var resolution = patterns.Resolve(context.Object);

            resolution.Should().Be("pattern1");
        }
コード例 #4
0
        public void MatchUsesFileSystemChecks()
        {
            var access = new Mock<IFileSystemRepositoryAccess>();
            var context = CreateContext();

            access.Setup(a => a.Exists("pattern1")).Returns(false);
            access.Setup(a => a.Exists("pattern2")).Returns(true);
            access.Setup(a => a.Exists("pattern3")).Returns(false);

            var patterns = new RepositoryPatternCollection(access.Object);
            patterns.AddPattern(new RepositoryPattern("pattern1"));
            patterns.AddPattern(new RepositoryPattern("pattern2"));
            patterns.AddPattern(new RepositoryPattern("pattern3"));

            var resolution = patterns.Resolve(context.Object);

            resolution.Should().Be("pattern2");
        }