Example #1
0
        public void SendXyz_ConnectionHandler_DisconnectAndConnectAreCalled_ForCertainHttpStatusCodes(HttpStatusCode statusCode)
        {
            _connectionManager = new ConnectionManager(_connectionHandler, _scheduler);
            _disposableCollection.Add(_dataTransportService = new DataTransportService(_connectionManager, _dateTimeStatic, _agentHealthReporter));

            Mock.Arrange(() => _connectionHandler.SendDataRequest <object>(Arg.IsAny <string>(), Arg.IsAny <object[]>()))
            .Throws(new HttpException(statusCode, null));

            _dataTransportService.Send(Arg.IsAny <EventHarvestData>(), Enumerable.Empty <TransactionEventWireModel>());

            Mock.Assert(() => _connectionHandler.Disconnect(), Occurs.Once());
            Mock.Assert(() => _connectionHandler.Connect(), Occurs.Once());
        }
Example #2
0
        public void SetUp()
        {
            _disposableCollection = new DisposableCollection();

            _configuration = Mock.Create <IConfiguration>();
            Mock.Arrange(() => _configuration.AgentRunId).Returns("MyAgentRunId");
            _disposableCollection.Add(new ConfigurationAutoResponder(_configuration));

            _connectionHandler   = Mock.Create <IConnectionHandler>();
            _scheduler           = Mock.Create <IScheduler>();
            _connectionManager   = Mock.Create <IConnectionManager>();
            _dateTimeStatic      = Mock.Create <IDateTimeStatic>();
            _agentHealthReporter = Mock.Create <IAgentHealthReporter>();
            _disposableCollection.Add(_dataTransportService = new DataTransportService(_connectionManager, _dateTimeStatic, _agentHealthReporter));
        }