コード例 #1
0
        public void CheckAttributeInSetup()
        {
            var resolver = new SnapshotSetupResolver();
            var setup    = resolver.ResolveSnapshotSetup();

            // attribute on
            setup.UpdateSnapshot.Should().BeTrue();
        }
コード例 #2
0
        public void CheckAttributeInSetupIsNotSet()
        {
            var resolver = new SnapshotSetupResolver();
            var setup    = resolver.ResolveSnapshotSetup();

            // no attribute set
            setup.UpdateSnapshot.Should().BeFalse();
        }
コード例 #3
0
        public void SnapshotIdResolver_ResolveSnapshotId()
        {
            var resolver = new SnapshotSetupResolver();
            var id       = resolver.ResolveSnapshotSetup();

            id.ClassName.Should().Be(@"SnapshotIdResolverTests");
            id.MethodName.Should().Be("SnapshotIdResolver_ResolveSnapshotId");
        }
コード例 #4
0
        public void AddMetadata()
        {
            var item = new { value = 1, data = "this is a test" };

            item.MatchSnapshot(() => new { id = 1 });


            var snapshotResolver = new SnapshotSetupResolver();
            var reader           = new SnapshotReader();
            var snapshots        = reader.Read(snapshotResolver.ResolveSnapshotSetup());

            snapshots.Count().Should().Be(1);
            snapshots.Single(s => s.Metadata["id"] == "1").Should().NotBeNull();
        }
コード例 #5
0
        public void NoSnapshot()
        {
            Action match = () => "test\r\nsnapshot".MatchSnapshot();

            match.Should().NotThrow();

            var resolver = new SnapshotSetupResolver();
            var file     = resolver.ResolveSnapshotSetup().GetFilePath();

            // Assert
            System.IO.File.Exists(file).Should().BeTrue();

            // cleanup
            System.IO.File.Delete(file);
        }
コード例 #6
0
        public void Update()
        {
            var resolver = new SnapshotSetupResolver();
            var reader = new SnapshotReader();
            var snapshots = reader.Read(resolver.ResolveSnapshotSetup());

            snapshots.Count().Should().Be(1);
            snapshots.Single().ToString().Should().Be("original string");

            "updated string".MatchSnapshot();

            snapshots = reader.Read(resolver.ResolveSnapshotSetup());

            snapshots.Count().Should().Be(1);
            snapshots.Single().ToString().Should().Be("updated string");


            "original string".MatchSnapshot();
        }
コード例 #7
0
        public void MatchMultipleSnapshotTokens()
        {
            var token = SnapshotTokenizer.Tokenize("test\r\nsnapshot\r\none")
                        .SetMetadata(() => new { id = "one" });

            Action match = () => token.MatchSnapshot();

            match.Should().NotThrow();

            token = SnapshotTokenizer.Tokenize("test\r\nsnapshot\r\ntwo")
                    .SetMetadata(() => new { id = "2" });

            match = () => token.MatchSnapshot();
            match.Should().NotThrow();

            var snapshotResolver = new SnapshotSetupResolver();
            var reader           = new SnapshotReader();
            var snapshots        = reader.Read(snapshotResolver.ResolveSnapshotSetup());

            snapshots.Count().Should().Be(2);
            snapshots.Any(s => s.Metadata["id"] == "one").Should().BeTrue();
            snapshots.Any(s => s.Metadata["id"] == "2").Should().BeTrue();
        }
コード例 #8
0
 public void Setup()
 {
     _snapshotResolver = new SnapshotSetupResolver();
 }