Beispiel #1
0
        public string ResolvePath(string snapshotName)
        {
            var (method, filePath) = XUnitTestHelper.GetCallingTestInfo();
            var directory = Path.GetDirectoryName(filePath);
            var snapName = string.IsNullOrWhiteSpace(snapshotName) ? method.Name : snapshotName;

            return Path.Combine(directory, "_snapshots", $"{snapName}.json");
        }
        public bool ShouldUpdateSnap()
        {
            if (_envUpdateDecider.ShouldUpdateSnap())
            {
                return(true);
            }

            var(method, _) = XUnitTestHelper.GetCallingTestInfo();

            var methodHasAttribute = method?.GetCustomAttributes(typeof(UpdateSnapshots), true).Any() ?? false;
            var classHasAttribute  = method?.ReflectedType?.GetCustomAttributes(typeof(UpdateSnapshots), true).Any() ?? false;

            return(methodHasAttribute || classHasAttribute);
        }