Beispiel #1
0
        public async Task <bool> UndeleteEvent <TDataType>(TDataType data) where TDataType : DataEntity
        {
            using (_logger.BeginScope("{Operation} is logging an {Action} for {DataType}", nameof(FileAuditWorker),
                                      "undelete event", typeof(TDataType).Name))
            {
                var currentLog = await ReadAllEvents <TDataType>(data.Id);

                return(await WriteEvent(GetFileName <TDataType>(data.Id), MaxAttempts <TDataType>(),
                                        () => AuditGenerator.UndeleteLog(data, currentLog)));
            }
        }
Beispiel #2
0
        public void UndeleteLog()
        {
            var data = new AuditedEntity
            {
                Id     = Randomizer.Next(),
                Value1 = Randomizer.GetString()
            };
            var auditLog = AuditGenerator.UndeleteLog(data, AuditGenerator.NewLog(data));

            Assert.AreEqual(2, auditLog.Entries.Count());
            Assert.AreEqual(AuditType.Undelete, auditLog.Entries.ElementAt(1).Type);
            Assert.AreEqual(2, auditLog.Entries.ElementAt(1).Changes.Count());
            Assert.IsTrue(auditLog.Entries.ElementAt(1).Changes.Any(x =>
                                                                    x.PropertyName == "Id" && x.NewValue.Equals(data.Id) && x.OldValue == null));
            Assert.IsTrue(auditLog.Entries.ElementAt(1).Changes.Any(x =>
                                                                    x.PropertyName == "Value1" && x.NewValue.Equals(data.Value1) && x.OldValue == null));
        }