コード例 #1
0
        public void Initialise()
        {
            _auditLogModelBuilder  = A.Fake <IAuditLogModelBuilder>();
            _dateTimeProvider      = A.Fake <IDateTimeProvider>();
            _userPrincipalProvider = A.Fake <IUserPrincipalProvider>();
            _commandDispatcher     = A.Fake <ICommandDispatcher>();
            _unitOfWork            = A.Fake <IUnitOfWork>();
            _auditFormatter        = A.Fake <IAuditFormatter>();

            A.CallTo(() => _dateTimeProvider.Now).Returns(_date);
            A.CallTo(() => _userPrincipalProvider.CurrentUserName).Returns(User);
            A.CallTo(() => _auditFormatter.AuditValues(A <IValueProvider> ._, A <string> ._)).Returns("default");

            var actionDescriptor = A.Fake <ActionDescriptor>();

            _controllerBase = A.Fake <ControllerBase>();

            A.CallTo(() => actionDescriptor.ActionName).Returns(Action);
            A.CallTo(() => actionDescriptor.ControllerDescriptor.ControllerName).Returns(Controller);

            _nameValueCollection          = new NameValueCollection();
            _nameValueProviderCollection  = new NameValueCollectionValueProvider(_nameValueCollection, null);
            _controllerBase.ValueProvider = _nameValueProviderCollection;

            _actionExecutingContext = new ActionExecutedContext()
            {
                ActionDescriptor = actionDescriptor,
                Controller       = _controllerBase
            };
        }
コード例 #2
0
        public AuditFilterAttribute(string auditProperties, ICommandDispatcher commandDispatcher, IUnitOfWork unitOfWork, IAuditLogModelBuilder auditLogModelBuilder, IUserPrincipalProvider userPrincipalProvider, IDateTimeProvider dateTimeProvider, IAuditFormatter auditFormatter)
        {
            if (string.IsNullOrWhiteSpace(auditProperties))
            {
                throw new ArgumentNullException();
            }

            _commandDispatcher     = commandDispatcher;
            _unitOfWork            = unitOfWork;
            _auditLogModelBuilder  = auditLogModelBuilder;
            _userPrincipalProvider = userPrincipalProvider;
            _dateTimeProvider      = dateTimeProvider;
            _auditFormatter        = auditFormatter;
            _auditProperties       = auditProperties;
        }