Ejemplo n.º 1
0
        public void Commit_Logs()
        {
            unitOfWork.Commit();

            logger.Received().Log(Arg.Any <IEnumerable <EntityEntry <BaseModel> > >());
            logger.Received().Save();
        }
Ejemplo n.º 2
0
        public void GivenAFhirRequest_WhenExecutingAnValidAction_ThenLogAuditMustBeCalled()
        {
            var executingContext = new ActionExecutingContext(
                new ActionContext(new DefaultHttpContext(), new RouteData(), new ControllerActionDescriptor()
            {
                DisplayName = "Executing Context Test Descriptor"
            }),
                new List <IFilterMetadata>(),
                _actionArguments,
                FilterTestsHelper.CreateMockFhirController());

            var descriptor = executingContext.ActionDescriptor as ControllerActionDescriptor;

            var claims = _claimsIndexer.Extract();

            descriptor.MethodInfo = typeof(FilterTestsHelper).GetMethod("MethodWithAuditEventAttribute");
            _filter.OnActionExecuting(executingContext);
            _auditLogger.Received(1).LogAudit(AuditAction.Executing, _fhirRequestContext.RequestSubType.Code, null, _fhirRequestContext.Uri, null, _fhirRequestContext.CorrelationId, _claims);
            _executedContext.ActionDescriptor = executingContext.ActionDescriptor;
            _filter.OnResultExecuted(_executedContext);
            _auditLogger.Received(2).LogAudit(Arg.Any <AuditAction>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Uri>(), Arg.Any <HttpStatusCode?>(), Arg.Any <string>(), Arg.Any <IReadOnlyCollection <KeyValuePair <string, string> > >());
            _auditLogger.Received(1).LogAudit(AuditAction.Executed, _fhirRequestContext.RequestSubType.Code, _fhirResult.Resource.TypeName, _fhirRequestContext.Uri, _fhirResult.StatusCode, _fhirRequestContext.CorrelationId, _claims);
        }
Ejemplo n.º 3
0
        public void WhenCreatingAnAccount_AMessageISWrittingToTheAuditLog()
        {
            sut.CreateAccount(new Account("123456", "Bucika", 0));

            auditLogger.Received().AddMessage(Arg.Is <string>(x => x.Contains("123456") && x.Contains("Bucika")));
        }
Ejemplo n.º 4
0
 public void WhenCreatingAnAccount_AMessageIsWrittenToTheAuditLog()
 {
     sut.CreateAccount(acc);
     iAuditLogger.Received().AddMessage(Arg.Is <string>(a => a.Contains(acc.Name) && a.Contains(acc.Number)));
 }