Example #1
0
        public void AddAuditEntry_StateUnderTest_CoverException()
        {
            _mockFeatureManager.Setup(p => p.IsEnabledAsync("EnableAudit"))
            .Returns(Task.FromResult(true));
            _mockAuditLogRepo.Setup(p => p.AddAsync(It.IsAny <AuditLogEntity>())).Throws <InvalidOperationException>();
            var           blogAudit     = CreateBlogAudit();
            BlogEventType blogEventType = BlogEventType.General;
            BlogEventId   auditEventId  = BlogEventId.SettingsSavedGeneral;
            string        message       = "Work 996 sick ICU";

            Assert.DoesNotThrowAsync(async() =>
            {
                await blogAudit.AddEntry(
                    blogEventType,
                    auditEventId,
                    message);
            });
        }
Example #2
0
        public async Task AddAuditEntry_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            _mockFeatureManager.Setup(p => p.IsEnabledAsync("EnableAudit"))
            .Returns(Task.FromResult(true));
            var           blogAudit     = CreateBlogAudit();
            BlogEventType blogEventType = BlogEventType.General;
            BlogEventId   auditEventId  = BlogEventId.SettingsSavedGeneral;
            string        message       = "Work 996 sick ICU";

            // Act
            await blogAudit.AddEntry(
                blogEventType,
                auditEventId,
                message);

            // Assert
            _mockAuditLogRepo.Verify(p => p.AddAsync(It.IsAny <AuditLogEntity>()));
        }