public void CheckAttributeInSetup() { var resolver = new SnapshotSetupResolver(); var setup = resolver.ResolveSnapshotSetup(); // attribute on setup.UpdateSnapshot.Should().BeTrue(); }
public void CheckAttributeInSetupIsNotSet() { var resolver = new SnapshotSetupResolver(); var setup = resolver.ResolveSnapshotSetup(); // no attribute set setup.UpdateSnapshot.Should().BeFalse(); }
public void SnapshotIdResolver_ResolveSnapshotId() { var resolver = new SnapshotSetupResolver(); var id = resolver.ResolveSnapshotSetup(); id.ClassName.Should().Be(@"SnapshotIdResolverTests"); id.MethodName.Should().Be("SnapshotIdResolver_ResolveSnapshotId"); }
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(); }
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); }
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(); }
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(); }
public void Setup() { _snapshotResolver = new SnapshotSetupResolver(); }