Resolve() 공개 메소드

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
리턴 PatternResolution
        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();
        }
        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();
        }
        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");
        }
        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");
        }