Esempio n. 1
0
        public AccessSafely AfterCompleting(int happenings)
        {
            _access = AccessSafely.AfterCompleting(happenings);

            _access.WritingWith <Response>("response", response => {
                var testId = response.HeaderValueOr(Client.ClientIdCustomHeader, "");

                _logger.WriteLine("{0:MM/dd/yyyy hh:mm:ss.fff} ID: {1}", DateTimeOffset.Now, testId);

                if (string.IsNullOrEmpty(testId))
                {
                    _logger.WriteLine("Expected header missing: {0}", Client.ClientIdCustomHeader);
                }

                if (_clientCounts.ContainsKey(testId))
                {
                    _clientCounts[testId] += 1;
                }
                else
                {
                    _clientCounts.Add(testId, 1);
                }

                ResponseHolder.Set(response);

                ResponseCount.IncrementAndGet();
            });
            _access.ReadingWith("response", () => ResponseHolder.Get());
            _access.ReadingWith("responseCount", () => ResponseCount.Get());
            _access.ReadingWith("responseClientCounts", () => _clientCounts);

            _access.WritingWith <int>("unknownResponseCount", increment => UnknownResponseCount.IncrementAndGet());
            _access.ReadingWith("unknownResponseCount", () => UnknownResponseCount.Get());

            _access.ReadingWith("totalAllResponseCount", () => ResponseCount.Get() + UnknownResponseCount.Get());

            return(_access);
        }
Esempio n. 2
0
        public AccessSafely AfterCompleting(int happenings)
        {
            _access = AccessSafely.AfterCompleting(happenings);

            _access.WritingWith <Response>("response", response => {
                var testId = response.HeaderValueOr(Client.ClientIdCustomHeader, "");

                _logger.WriteLine("ID: {0}", testId);

                if (string.IsNullOrEmpty(testId))
                {
                    _logger.WriteLine("Expected header missing: {0}", Client.ClientIdCustomHeader);
                    //throw new IllegalStateException("Expected header missing: " + Client.ClientIdCustomHeader);
                }

                int existingCount = 0;
                if (_clientCounts.ContainsKey(testId))
                {
                    existingCount = _clientCounts[testId];
                }

                ResponseHolder.Set(response);

                _clientCounts.Add(testId, existingCount + 1);

                ResponseCount.IncrementAndGet();
            });
            _access.ReadingWith("response", () => ResponseHolder.Get());
            _access.ReadingWith("responseCount", () => ResponseCount.Get());
            _access.ReadingWith("responseClientCounts", () => _clientCounts);

            _access.WritingWith <int>("unknownResponseCount", increment => UnknownResponseCount.IncrementAndGet());
            _access.ReadingWith("unknownResponseCount", () => UnknownResponseCount.Get());

            _access.ReadingWith("totalAllResponseCount", () => ResponseCount.Get() + UnknownResponseCount.Get());

            return(_access);
        }