Verify() public static method

public static Verify ( string beforeAssemblyPath, string afterAssemblyPath ) : void
beforeAssemblyPath string
afterAssemblyPath string
return void
コード例 #1
0
 public void Verify()
 {
     var path = TestData(Location);
     using (var verifier = new Verifier(path))
     {
         var activeSignature = (WebBase64) File.ReadAllLines(Path.Combine(path, "1.out")).First();
         var primarySignature = (WebBase64) File.ReadAllLines(Path.Combine(path, "2.out")).First();
         Expect(verifier.Verify(Input, activeSignature), Is.True);
         Expect(verifier.Verify(Input, primarySignature), Is.True);
     }
 }
コード例 #2
0
 protected void HelperVerifyVariousSizes(string size)
 {
     var path = TestData(Location) + "-size";
     using (var verifier = new Verifier(path))
     {
         var activeSignature = (WebBase64) File.ReadAllLines(Path.Combine(path, size + ".out")).First();
         Expect(verifier.Verify(Input, activeSignature), Is.True);
     }
 }
コード例 #3
0
ファイル: VerifyTask.cs プロジェクト: GeertvanHorrik/Fody
 public override bool Execute()
 {
     var defineConstants = DefineConstants.GetConstants();
     var verifier = new Verifier
                    {
                        Logger = new BuildLogger
                                 {
                                     BuildEngine = BuildEngine,
                                 },
                        SolutionDirectory= SolutionDir,
                        ProjectDirectory = ProjectDirectory,
                        DefineConstants = defineConstants,
                        TargetPath = TargetPath,
                    };
     return verifier.Verify();
 }
コード例 #4
0
 public Task CheckInvalidWordWithQuestionMark()
 {
     return(Verifier.Verify(ContentValidation.Verify(" you? ")));
 }
コード例 #5
0
 public void TestSignImport([Values("rsa", "dsa")] String keyType, [Values("pem", "der")] String fileFormat)
 {
     using (var signer = new Signer(Util.TestDataPath(TEST_DATA, keyType + "-sign")))
     {
         var signature = signer.Sign(input);
         using (
             var keyset = ImportedKeySet.Import.X509Certificate(KeyPurpose.Verify,
                                                                Util.TestDataPath(TEST_DATA,
                                                                                  keyType + "-sign-crt." +
                                                                                  fileFormat)))
         using (var verifier = new Verifier(keyset))
         {
             Expect(verifier.Verify(input, signature), Is.True);
         }
     }
 }
コード例 #6
0
ファイル: SignerTest.cs プロジェクト: jbtule/keyczar-dotnet
        public void TestPublicVerify(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);

            using (var verifier = new Verifier(subPath))
            using (var publicVerifier = new Verifier(subPath + ".public"))
            {
                var activeSignature = (WebBase64) File.ReadAllLines(Path.Combine(subPath, "1.out")).First();
                var primarySignature = (WebBase64) File.ReadAllLines(Path.Combine(subPath, "2.out")).First();

                Expect(verifier.Verify(input, activeSignature), Is.True);
                Expect(verifier.Verify(input, primarySignature), Is.True);
                Expect(publicVerifier.Verify(input, activeSignature), Is.True);
                Expect(publicVerifier.Verify(input, primarySignature), Is.True);
            }
        }
コード例 #7
0
 public Task PostIntrospection()
 {
     return(Verifier.Verify(executor.ExecutePost(IntrospectionQuery)));
 }
コード例 #8
0
 public async Task Default()
 {
     using var target = new HotKeyControl();
     await Verifier.Verify(target);
 }
コード例 #9
0
        public Task ProjectSystem()
        {
            IEnumerable <string> files = GetPackageContents("ProjectSystem.vsix");

            return(Verifier.Verify(files));
        }
コード例 #10
0
        public Task CommonFiles()
        {
            IEnumerable <string> files = GetPackageContents("Microsoft.VisualStudio.ProjectSystem.Managed.CommonFiles.vsix");

            return(Verifier.Verify(files));
        }
コード例 #11
0
        public void PeVerify()
        {
            var weaver = AssemblyWeaver.Instance;

            Verifier.Verify(weaver.BeforeAssemblyPath, weaver.AfterAssemblyPath);
        }
コード例 #12
0
 public void UseCurlyBraces()
 {
     Verifier.Verify(@"TestCases\UseCurlyBraces.cs", new UseCurlyBraces());
 }
コード例 #13
0
 public Task CheckInvalidWordIndicatesAllViolationsInTheExceptionMessageIgnoringCase()
 {
     return(Verifier.Verify(ContentValidation.Verify(" you, and you again! Still Yourself? Us")));
 }
コード例 #14
0
 public Task MemberDataUsageFluent(string arg)
 {
     return(Verifier.Verify(arg)
            .UseParameters(arg));
 }
コード例 #15
0
 public void PeVerify()
 {
     Verifier.Verify(afterAssemblyPath);
 }
コード例 #16
0
 public void UnusedLocalVariable()
 {
     Verifier.Verify(@"TestCases\UnusedLocalVariable.cs", new UnusedLocalVariable());
 }
コード例 #17
0
 public void AsyncAwaitIdentifier()
 {
     Verifier.Verify(@"TestCases\AsyncAwaitIdentifier.cs", new AsyncAwaitIdentifier());
 }
コード例 #18
0
        public int Run()
        {
            if (_suppressError)
            {
                Console.SetError(StreamWriter.Null);
            }

            if (!Directory.Exists(_path) && !File.Exists(_path))
            {
                Console.Error.WriteLine("Error: Not a valid file or directory {0}", _path);

                return((int)ExitCode.CriticalError);
            }

            Verifier?verifier = null;

            if (_rulespath.Count() > 0)
            {
                // Setup the rules
                verifier = new Verifier(_rulespath);
                if (!verifier.Verify())
                {
                    return((int)ExitCode.CriticalError);
                }

                if (verifier.CompiledRuleset.Count() == 0 && _ignoreDefaultRules)
                {
                    Console.Error.WriteLine("Error: No rules were loaded. ");
                    return((int)ExitCode.CriticalError);
                }
            }

            RuleSet rules = new RuleSet();

            if (verifier != null)
            {
                rules = verifier.CompiledRuleset;
            }

            if (!_ignoreDefaultRules)
            {
                Assembly?assembly = Assembly.GetAssembly(typeof(Boundary));
                string   filePath = "Microsoft.DevSkim.Resources.devskim-rules.json";
                Stream?  resource = assembly?.GetManifestResourceStream(filePath);
                if (resource is Stream)
                {
                    using (StreamReader file = new StreamReader(resource))
                    {
                        rules.AddString(file.ReadToEnd(), filePath, null);
                    }
                }
            }

            // Initialize the processor
            RuleProcessor processor = new RuleProcessor(rules);

            processor.EnableSuppressions = !_disableSuppression;

            if (_severities.Count() > 0)
            {
                processor.SeverityLevel = 0;
                foreach (string severityText in _severities)
                {
                    Severity severity;
                    if (ParseSeverity(severityText, out severity))
                    {
                        processor.SeverityLevel |= severity;
                    }
                    else
                    {
                        Console.Error.WriteLine("Invalid severity: {0}", severityText);
                        return((int)ExitCode.CriticalError);
                    }
                }
            }

            Writer outputWriter = WriterFactory.GetWriter(string.IsNullOrEmpty(_fileFormat) ? string.IsNullOrEmpty(_outputFile) ? "_dummy" : "text" : _fileFormat,
                                                          _outputFormat,
                                                          string.IsNullOrEmpty(_outputFile) ? Console.Out : File.CreateText(_outputFile));

            int filesAnalyzed = 0;
            int filesSkipped  = 0;
            int filesAffected = 0;
            int issuesCount   = 0;

            // We can pass either a file or a directory; if it's a file, make an IEnumerable out of it.
            IEnumerable <string> fileListing;

            if (!Directory.Exists(_path))
            {
                fileListing = new List <string>()
                {
                    _path
                };
            }
            else
            {
                fileListing = Directory.EnumerateFiles(_path, "*.*", SearchOption.AllDirectories);
            }

            // Iterate through all files
            foreach (string filename in fileListing)
            {
                string language = Language.FromFileName(filename);

                // Skip files written in unknown language
                if (string.IsNullOrEmpty(language))
                {
                    filesSkipped++;
                    continue;
                }

                string fileText = string.Empty;
                try
                {
                    fileText = File.ReadAllText(filename);
                    filesAnalyzed++;
                }
                catch (Exception)
                {
                    // Skip files we can't parse
                    filesSkipped++;
                    continue;
                }

                Issue[] issues = processor.Analyze(fileText, language);

                bool issuesFound = issues.Any(iss => iss.IsSuppressionInfo == false) || _disableSuppression && issues.Count() > 0;

                if (issuesFound)
                {
                    filesAffected++;
                    Console.Error.WriteLine("file:{0}", filename);

                    // Iterate through each issue
                    foreach (Issue issue in issues)
                    {
                        if (!issue.IsSuppressionInfo || _disableSuppression)
                        {
                            issuesCount++;
                            Console.Error.WriteLine("\tregion:{0},{1},{2},{3} - {4} [{5}] - {6}",
                                                    issue.StartLocation.Line,
                                                    issue.StartLocation.Column,
                                                    issue.EndLocation.Line,
                                                    issue.EndLocation.Column,
                                                    issue.Rule.Id,
                                                    issue.Rule.Severity,
                                                    issue.Rule.Name);

                            IssueRecord record = new IssueRecord(
                                Filename: filename,
                                Filesize: fileText.Length,
                                TextSample: fileText.Substring(issue.Boundary.Index, issue.Boundary.Length),
                                Issue: issue);

                            outputWriter.WriteIssue(record);
                        }
                    }

                    Console.Error.WriteLine();
                }
            }

            outputWriter.FlushAndClose();

            Console.Error.WriteLine("Issues found: {0} in {1} files", issuesCount, filesAffected);
            Console.Error.WriteLine("Files analyzed: {0}", filesAnalyzed);
            Console.Error.WriteLine("Files skipped: {0}", filesSkipped);

            return(issuesCount > 0 ? (int)ExitCode.IssuesExists : (int)ExitCode.NoIssues);
        }
コード例 #19
0
 public void BooleanCheckInverted()
 {
     Verifier.Verify(@"TestCases\BooleanCheckInverted.cs", new BooleanCheckInverted());
 }
コード例 #20
0
    private static SettingsTask Verify(StringWriter output)
    {
        var xml = output.ToString();

        return(Verifier.Verify(xml).UseExtension("xml"));
    }
コード例 #21
0
 public Task CheckInvalidWordWithComma()
 {
     return(Verifier.Verify(ContentValidation.Verify(" you, ")));
 }
コード例 #22
0
 public void PeVerify()
 {
     Verifier.Verify(OriginalPath, ModifiedPath);
 }
コード例 #23
0
 public Task CheckInvalidWordStringEnd()
 {
     return(Verifier.Verify(ContentValidation.Verify("the you")));
 }
コード例 #24
0
 public void CatchRethrow()
 {
     Verifier.Verify(@"TestCases\CatchRethrow.cs", new CatchRethrow());
 }
コード例 #25
0
 public Task CheckInvalidWord()
 {
     return(Verifier.Verify(ContentValidation.Verify(" you ")));
 }
コード例 #26
0
        public Task VisualStudioEditorsSetup()
        {
            IEnumerable <string> files = GetPackageContents("VisualStudioEditorsSetup.vsix");

            return(Verifier.Verify(files));
        }
コード例 #27
0
 public Task Test(string value)
 {
     return(Verifier.Verify(value)
            .UseParameters(value));
 }
コード例 #28
0
 public void PeVerify()
 {
     Verifier.Verify(beforeAssemblyPath, afterAssemblyPath);
 }
コード例 #29
0
ファイル: WeaverTests.cs プロジェクト: wk-j/basic-fody-addin
 public void PeVerify()
 {
     Verifier.Verify(assemblyPath, newAssemblyPath);
 }
コード例 #30
0
 public static void TestAll()
 {
     try
     {
         Console.WriteLine("Running tests for 20xx");
         Verifier.Verify(0, Day01.Part1(), "day 1 part 1");
         Verifier.Verify(0, Day01.Part2(), "day 1 part 2");
         Verifier.Verify(0, Day02.Part1(), "day 2 part 1");
         Verifier.Verify(0, Day02.Part2(), "day 2 part 1");
         Verifier.Verify(0, Day03.Part1(), "day 3 part 1");
         Verifier.Verify(0, Day03.Part2(), "day 3 part 2");
         Verifier.Verify(0, Day04.Part1(), "day 4 part 1");
         Verifier.Verify(0, Day04.Part2(), "day 4 part 2");
         Verifier.Verify(0, Day05.Part1(), "day 5 part 1");
         Verifier.Verify(0, Day05.Part2(), "day 5 part 2");
         Verifier.Verify(0, Day06.Part1(), "day 6 part 1");
         Verifier.Verify(0, Day06.Part2(), "day 6 part 2");
         Verifier.Verify(0, Day07.Part1(), "day 7 part 1");
         Verifier.Verify(0, Day07.Part2(), "day 7 part 2");
         Verifier.Verify(0, Day08.Part1(), "day 8 part 1");
         Verifier.Verify(0, Day08.Part2(), "day 8 part 2");
         Verifier.Verify(0, Day09.Part1(), "day 9 part 1");
         Verifier.Verify(0, Day09.Part2(), "day 9 part 2");
         Verifier.Verify(0, Day10.Part1(), "day 10 part 1");
         Verifier.Verify(0, Day10.Part2(), "day 10 part 2");
         Verifier.Verify(0, Day11.Part1(), "day 11 part 1");
         Verifier.Verify(0, Day11.Part2(), "day 11 part 2");
         Verifier.Verify(0, Day12.Part1(), "day 12 part 1");
         Verifier.Verify(0, Day12.Part2(), "day 12 part 2");
         Verifier.Verify(0, Day13.Part1(), "day 13 part 1");
         Verifier.Verify(0, Day13.Part2(), "day 13 part 2");
         Verifier.Verify(0, Day14.Part1(), "day 14 part 1");
         Verifier.Verify(0, Day14.Part2(), "day 14 part 2");
         Verifier.Verify(0, Day15.Part1(), "day 15 part 1");
         Verifier.Verify(0, Day15.Part2(), "day 15 part 2");
         Verifier.Verify(0, Day16.Part1(), "day 16 part 1");
         Verifier.Verify(0, Day16.Part2(), "day 16 part 2");
         Verifier.Verify(0, Day17.Part1(), "day 17 part 1");
         Verifier.Verify(0, Day17.Part2(), "day 17 part 2");
         Verifier.Verify(0, Day18.Part1(), "day 18 part 1");
         Verifier.Verify(0, Day18.Part2(), "day 18 part 2");
         Verifier.Verify(0, Day19.Part1(), "day 19 part 1");
         Verifier.Verify(0, Day19.Part2(), "day 19 part 2");
         Verifier.Verify(0, Day20.Part1(), "day 20 part 1");
         Verifier.Verify(0, Day20.Part2(), "day 20 part 2");
         Verifier.Verify(0, Day21.Part1(), "day 21 part 1");
         Verifier.Verify(0, Day21.Part2(), "day 21 part 2");
         Verifier.Verify(0, Day22.Part1(), "day 22 part 1");
         Verifier.Verify(0, Day22.Part2(), "day 22 part 2");
         Verifier.Verify(0, Day23.Part1(), "day 23 part 1");
         Verifier.Verify(0, Day23.Part2(), "day 23 part 2");
         Verifier.Verify(0, Day24.Part1(), "day 24 part 1");
         Verifier.Verify(0, Day24.Part2(), "day 24 part 2");
         Verifier.Verify(0, Day25.Part1(), "day 25 part 1");
         Console.WriteLine("All tests for 20xx OK");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
 public void SelfAssignedVariables()
 {
     Verifier.Verify(@"TestCases\SelfAssignedVariables.cs", new SelfAssignedVariables());
 }
コード例 #32
0
    public Task ShouldIgnoreDatetimeDefaults()
    {
        DateTimeTarget target = new();

        return(Verifier.Verify(target));
    }
コード例 #33
0
    public async Task InheritedEntityInterface()
    {
        var query = @"
{
  interfaceGraphConnection {
    items {
      ...inheritedEntityFields
    }
  }
}
fragment inheritedEntityFields on InterfaceGraph {
  property
  childrenFromInterface(orderBy: {path: ""property""})
  {
    items {
      ...childEntityFields
    }
  }
  ... on DerivedWithNavigationGraph {
    childrenFromDerived(orderBy: {path: ""property""})
    {
      items {
        ...childEntityFields
      }
    }
  }
}
fragment childEntityFields on DerivedChildGraph {
  property
}";

        var derivedEntity1 = new DerivedEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var childEntity1 = new DerivedChildEntity
        {
            Property = "Value2",
            Parent   = derivedEntity1
        };
        var childEntity2 = new DerivedChildEntity
        {
            Property = "Value3",
            Parent   = derivedEntity1
        };

        derivedEntity1.ChildrenFromBase.Add(childEntity1);
        derivedEntity1.ChildrenFromBase.Add(childEntity2);

        var derivedEntity2 = new DerivedWithNavigationEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000002"),
            Property = "Value4"
        };
        var childEntity3 = new DerivedChildEntity
        {
            Property = "Value5",
            Parent   = derivedEntity2
        };
        var childEntity4 = new DerivedChildEntity
        {
            Property    = "Value6",
            TypedParent = derivedEntity2
        };

        derivedEntity2.ChildrenFromBase.Add(childEntity3);
        derivedEntity2.Children.Add(childEntity4);

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, false, derivedEntity1, childEntity1, childEntity2, derivedEntity2, childEntity3, childEntity4);

        await Verifier.Verify(result);
    }
コード例 #34
0
        public void TestSignImport(
            [Values("rsa", "dsa")] string keyType,
            [Values("pem", "der")] string format)
        {
            using (var keystream = HelperOpenPkcsStream(keyType, format, "sign"))
            using (
                var keyset = ImportedKeySet.Import.PkcsKey(KeyPurpose.SignAndVerify, keystream, () => "pass"
                    /* hard coding for test only!!!!*/))
            using (var signer = new Signer(keyset))

            {
                var signature = signer.Sign(input);
                using (var verifier = new Verifier(Util.TestDataPath(TEST_DATA, keyType + "-sign-pub")))
                {
                    Expect(verifier.Verify(input, signature), Is.True);
                }
            }
        }
コード例 #35
0
 public Task Simple()
 {
     return(Verifier.Verify("Foo"));
 }
コード例 #36
0
ファイル: SignerTest.cs プロジェクト: jbtule/keyczar-dotnet
        public void TestPublicVerifySizes(String subDir, string nestDir)
        {
            var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir);
            var ks = new KeySet(subPath);
            using (var verifier = new Verifier(subPath))
            using (var publicVerifier = new Verifier(subPath + ".public"))
            {
                foreach (var size in ks.Metadata.KeyType.KeySizeOptions)
                {
                    var activeSignature =
                        (WebBase64) File.ReadAllLines(Path.Combine(subPath, String.Format("{0}.out", size))).First();

                    Expect(verifier.Verify(input, activeSignature), Is.True);
                    Expect(publicVerifier.Verify(input, activeSignature), Is.True);
                }
            }
        }
コード例 #37
0
ファイル: StaticSettings.cs プロジェクト: surrealist/Verify
 public Task Test()
 {
     return(Verifier.Verify("String to verify"));
 }