Ejemplo n.º 1
0
        public void IStateAuditLogger_SubscribeToEventNotifications_Tests()
        {
            TestSetup(out _fileWrapper, out _directoryWrapper, out _activity);
            var nextActivityMock = new Mock <IDev2Activity>();
            var nextActivity     = nextActivityMock.Object;
            var exception        = new Exception("some exception");
            var message          = new { Message = "Some Message" };
            var detailMethodName = nameof(IStateAuditLogger_SubscribeToEventNotifications_Tests);

            var notifier        = new StateNotifier();
            var stateLoggerMock = new Mock <IStateListener>();

            stateLoggerMock.Setup(o => o.LogPreExecuteState(_activity.Object)).Verifiable();
            stateLoggerMock.Setup(o => o.LogPostExecuteState(_activity.Object, nextActivity)).Verifiable();
            stateLoggerMock.Setup(o => o.LogExecuteException(exception, nextActivity)).Verifiable();
            stateLoggerMock.Setup(o => o.LogAdditionalDetail(message, detailMethodName)).Verifiable();
            stateLoggerMock.Setup(o => o.LogExecuteCompleteState(nextActivity)).Verifiable();
            stateLoggerMock.Setup(o => o.LogStopExecutionState(nextActivity)).Verifiable();
            var listener = stateLoggerMock.Object;

            // test
            notifier.Subscribe(listener);

            notifier.LogPreExecuteState(_activity.Object);
            notifier.LogPostExecuteState(_activity.Object, nextActivity);
            notifier.LogExecuteException(exception, nextActivity);
            notifier.LogAdditionalDetail(message, detailMethodName);
            notifier.LogExecuteCompleteState(nextActivity);
            notifier.LogStopExecutionState(nextActivity);

            // verify
            stateLoggerMock.Verify();
            notifier.Dispose();
        }
Ejemplo n.º 2
0
        private IStateNotifier GetStateNotifier(IDSFDataObject dsfDataObject)
        {
            // TODO: check if there is already a state notifier for this workflow
            //       in this server instance. Re-use either the notifier or its loggers.
            var stateNotifier = new StateNotifier();

            if (dsfDataObject.Settings.EnableDetailedLogging)
            {
                stateNotifier.Subscribe(new Dev2StateAuditLogger(dsfDataObject));
            }
            return(stateNotifier);
        }
Ejemplo n.º 3
0
        public IStateNotifier CreateStateNotifierImpl(IDSFDataObject dsfDataObject)
        {
            var stateNotifier = new StateNotifier();

            if (dsfDataObject.Settings.EnableDetailedLogging)
            {
                _logger = new StateAuditLogger(new WebSocketFactory());
                stateNotifier.Subscribe(_logger.NewStateListener(dsfDataObject));
            }

            return(stateNotifier);
        }
Ejemplo n.º 4
0
        private IStateNotifier GetStateNotifier(IDSFDataObject dsfDataObject)
        {
            // TODO: check if there is already a state notifier for this workflow
            //       in this server instance. Re-use either the notifier or its loggers.
            var stateNotifier = new StateNotifier();

            stateNotifier.Subscribe(new Dev2StateAuditLogger(dsfDataObject));

            if (dsfDataObject.Settings.EnableDetailedLogging)
            {
                if (dsfDataObject.Settings.LoggerType == LoggerType.JSON)
                {
                    stateNotifier.Subscribe(new Dev2JsonStateLogger(dsfDataObject));
                }
                else
                {
                    throw new Exception("logger not implemented");
                }
            }
            return(stateNotifier);
        }
Ejemplo n.º 5
0
        public void StateNotifier_SubscribeToEventNotifications_Test()
        {
            var activityMock = new Mock <IDev2Activity>();
            var activity     = activityMock.Object;

            var nextActivityMock = new Mock <IDev2Activity>();
            var nextActivity     = nextActivityMock.Object;

            var exception = new Exception("some exception");

            var additionalDetailObject     = new { Message = "Some Message" };
            var additionalDetailMethodName = nameof(StateNotifier_SubscribeToEventNotifications_Test);

            using (var notifier = new StateNotifier())
            {
                var listenerMock = new Mock <IStateListener>();
                listenerMock.Setup(o => o.LogPreExecuteState(activity)).Verifiable();
                listenerMock.Setup(o => o.LogPostExecuteState(activity, nextActivity)).Verifiable();
                listenerMock.Setup(o => o.LogExecuteException(exception, nextActivity)).Verifiable();
                listenerMock.Setup(o => o.LogAdditionalDetail(It.IsAny <object>(), It.IsAny <string>())).Verifiable();
                listenerMock.Setup(o => o.LogExecuteCompleteState(activity)).Verifiable();
                listenerMock.Setup(o => o.LogStopExecutionState(activity)).Verifiable();
                var listener = listenerMock.Object;
                // test
                notifier.Subscribe(listener);

                notifier.LogPreExecuteState(activity);
                notifier.LogPostExecuteState(activity, nextActivity);
                notifier.LogExecuteException(exception, nextActivity);
                notifier.LogAdditionalDetail(additionalDetailObject, additionalDetailMethodName);
                notifier.LogExecuteCompleteState(activity);
                notifier.LogStopExecutionState(activity);

                // verify
                listenerMock.Verify();
            }
        }