public void Fingerprint_FileRelative() { string workingDir = Path.GetDirectoryName(path1); string relPath1 = Path.GetFileName(path1); string relPath2 = Path.GetFileName(path2); using (var hostContext = new TestHostContext(this)) { var context = new AgentTaskPluginExecutionContext(hostContext.GetTrace()); context.SetVariable( "system.defaultworkingdirectory", // Constants.Variables.System.DefaultWorkingDirectory workingDir, isSecret: false); var segments = new[] { $"{relPath1}", $"{relPath2}", }; Fingerprint f = FingerprintCreator.EvaluateKeyToFingerprint(context, directory, segments); var file1 = new FingerprintCreator.MatchedFile(relPath1, content1.Length, hash1.ToHex()); var file2 = new FingerprintCreator.MatchedFile(relPath2, content2.Length, hash2.ToHex()); Assert.Equal(2, f.Segments.Length); Assert.Equal(file1.GetHash(), f.Segments[0]); Assert.Equal(file2.GetHash(), f.Segments[1]); } }
public void Fingerprint_ExcludeExactMisses() { using (var hostContext = new TestHostContext(this)) { var context = new AgentTaskPluginExecutionContext(hostContext.GetTrace()); var segments = new[] { $"{path1},!{path2}", }; Fingerprint f = FingerprintCreator.EvaluateKeyToFingerprint(context, directory, segments); Assert.Equal(1, f.Segments.Length); var matchedFile = new FingerprintCreator.MatchedFile(Path.GetFileName(path1), content1.Length, hash1.ToHex()); Assert.Equal(matchedFile.GetHash(), f.Segments[0]); } }
public void Fingerprint_FileAbsolute() { using (var hostContext = new TestHostContext(this)) { var context = new AgentTaskPluginExecutionContext(hostContext.GetTrace()); var segments = new[] { $"{path1}", $"{path2}", }; Fingerprint f = FingerprintCreator.EvaluateKeyToFingerprint(context, directory, segments); var file1 = new FingerprintCreator.MatchedFile(Path.GetFileName(path1), content1.Length, hash1.ToHex()); var file2 = new FingerprintCreator.MatchedFile(Path.GetFileName(path2), content2.Length, hash2.ToHex()); Assert.Equal(2, f.Segments.Length); Assert.Equal(file1.GetHash(), f.Segments[0]); Assert.Equal(file2.GetHash(), f.Segments[1]); } }