public string ResolvePath(string snapshotName) { var(method, filePath) = NUnitTestHelper.GetCallingTestInfo(); var directory = Path.GetDirectoryName(filePath); var className = method.DeclaringType?.Name; var snapName = string.IsNullOrWhiteSpace(snapshotName) ? $"{className}{'_'}{method.Name}" : $"{className}{'_'}{snapshotName}"; return(Path.Combine(directory, "_snapshots", $"{snapName}.json")); }
public bool ShouldUpdateSnap() { if (_envUpdateDecider.ShouldUpdateSnap()) { return(true); } var(method, _) = NUnitTestHelper.GetCallingTestInfo(); var methodHasAttribute = method?.GetCustomAttributes(typeof(UpdateSnapshots), true).Any() ?? false; var classHasAttribute = method?.ReflectedType?.GetCustomAttributes(typeof(UpdateSnapshots), true).Any() ?? false; return(methodHasAttribute || classHasAttribute); }