public void Constructor_AcceptsNulls() { var entry = new AuditEntry(record: null, actor: null); Assert.Null(entry.Record); Assert.Null(entry.Actor); }
/// <summary> /// Renders an audit entry as JSON. /// </summary> /// <param name="entry">An audit entry.</param> /// <returns>A JSON string.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="entry" /> is <c>null</c>.</exception> public virtual string RenderAuditEntry(AuditEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } return(JsonConvert.SerializeObject(entry, AuditRecordSerializerSettings)); }
public virtual async Task<Uri> SaveAuditRecord(AuditRecord record) { // Build an audit entry var entry = new AuditEntry(record, await GetActor()); // Serialize to json string rendered = RenderAuditEntry(entry); // Save the record return await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc); }
public virtual async Task <Uri> SaveAuditRecord(AuditRecord record) { // Build an audit entry var entry = new AuditEntry(record, await GetActor()); // Serialize to json string rendered = RenderAuditEntry(entry); // Save the record return(await SaveAuditRecord(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc)); }
public override string RenderAuditEntry(AuditEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } var settings = GetJsonSerializerSettings(); settings.Converters.Add(new ObfuscatorJsonConverter(entry)); return(JsonConvert.SerializeObject(entry, settings)); }
/// <summary> /// Persists the audit record to storage. /// </summary> /// <param name="record">An audit record.</param> /// <returns>A <see cref="Task"/> that represents the asynchronous save operation.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="record" /> is <c>null</c>.</exception> public async Task SaveAuditRecordAsync(AuditRecord record) { if (record == null) { throw new ArgumentNullException(nameof(record)); } var entry = new AuditEntry(record, await GetActorAsync()); var rendered = RenderAuditEntry(entry); await SaveAuditRecordAsync(rendered, record.GetResourceType(), record.GetPath(), record.GetAction(), entry.Actor.TimestampUtc); }
public void Constructor_SetsProperties() { var record = new Mock <AuditRecord>(); var actor = new AuditActor( machineName: null, machineIP: null, userName: null, authenticationType: null, timeStampUtc: DateTime.MinValue); var entry = new AuditEntry(record.Object, actor); Assert.Same(record.Object, entry.Record); Assert.Same(actor, entry.Actor); }
public virtual string RenderAuditEntry(AuditEntry entry) { return JsonConvert.SerializeObject(entry, _auditRecordSerializerSettings); }
public virtual string RenderAuditEntry(AuditEntry entry) { return(JsonConvert.SerializeObject(entry, _auditRecordSerializerSettings)); }