Пример #1
0
        public virtual async Task Should_Not_Write_AuditLog_For_Entity_That_Has_DisableAuditing_Attribute()
        {
            using (var scope = _auditingManager.BeginScope())
            {
                var repository = ServiceProvider.GetRequiredService <IBasicRepository <AppEntityWithDisableAuditing, Guid> >();
                await repository.InsertAsync(new AppEntityWithDisableAuditing(Guid.NewGuid(), "test name")).ConfigureAwait(false);

                await scope.SaveAsync().ConfigureAwait(false);
            }

#pragma warning disable 4014
            _auditingStore.DidNotReceive().SaveAsync(Arg.Any <AuditLogInfo>());
#pragma warning restore 4014
        }
Пример #2
0
        public async Task RazorPage_RazorAuditPageFilter_Get_Test(string pageName, bool shouldWriteAuditLog)
        {
            // Arrange
            var client = _factory.CreateClient();

            // Act
            var response = await client.GetAsync("/" + pageName);

            // Assert
            response.EnsureSuccessStatusCode();

#pragma warning disable 4014

            if (shouldWriteAuditLog)
            {
                _auditingStore.Received().SaveAsync(Arg.Is <AuditInfo>(a => a.ServiceName.Contains(pageName)));
            }
            else
            {
                _auditingStore.DidNotReceive().SaveAsync(Arg.Any <AuditInfo>());
            }

#pragma warning restore 4014
        }