Skip to content

Extend AssemblyAssertions with methods to check on assemblies being signed or not #2209

@Corniel

Description

@Corniel

Background and motivation

To ensure that the public key of an signed assembly does not accidentally changes, having an assertion .HavePublicKey(string) can help. For completeness/symmetry reasons adding .BeUnsigned() might be beneficial too.

API Proposal

public class AssemblyAssertions : ReferenceTypeAssertions<Assembly, AssemblyAssertions>
{
    public AndConstraint<AssemblyAssertions> NotHavePublicKey(string because = "", params object[] becauseArgs);

    public AndConstraint<AssemblyAssertions> HavePublicKey(string publicKey, string because = "", params object[] becauseArgs);
}

API Usage

var signed = typeof(AssemblyA.ClassA).Assembly;
signed.Should().HavePublicKey("sdfds");

var unsigned = typeof(AssemblyB.ClassB).Assembly;
unsigned.Should().NotHavePublicKey();

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved, it can be implemented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions