public void Constructor_SetsProperties() { var identifier = new AuditedPackageIdentifier(id: "a", version: "1.0.0"); var credential = new Credential(type: CredentialTypes.Password.V3, value: "b"); var record = new FailedAuthenticatedOperationAuditRecord( usernameOrEmail: "c", action: AuditedAuthenticatedOperationAction.PackagePushAttemptByNonOwner, attemptedPackage: identifier, attemptedCredential: credential); Assert.Equal("c", record.UsernameOrEmail); Assert.Same(identifier, record.AttemptedPackage); Assert.NotNull(record.AttemptedCredential); Assert.Equal(credential.Type, record.AttemptedCredential.Type); Assert.Null(record.AttemptedCredential.Value); Assert.Equal(AuditedAuthenticatedOperationAction.PackagePushAttemptByNonOwner, record.Action); }
public FailedAuthenticatedOperationAuditRecord( string usernameOrEmail, AuditedAuthenticatedOperationAction action, AuditedPackageIdentifier attemptedPackage = null, Credential attemptedCredential = null) : base(action) { UsernameOrEmail = usernameOrEmail; if (attemptedPackage != null) { AttemptedPackage = attemptedPackage; } if (attemptedCredential != null) { AttemptedCredential = new CredentialAuditRecord(attemptedCredential, removed: false); } }