Ping() public method

public Ping ( string instrumentationKey, DateTimeOffset timestamp ) : bool?
instrumentationKey string
timestamp DateTimeOffset
return bool?
        public void QuickPulseServiceClientDoesNotRetryPing()
        {
            // ARRANGE
            var serviceClient = new QuickPulseServiceClient(
                this.serviceEndpoint,
                string.Empty,
                string.Empty,
                new Clock(),
                TimeSpan.FromMilliseconds(50));

            this.emulateTimeout = true;

            // ACT
            serviceClient.Ping(string.Empty, DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.AreEqual(1, this.pingCount);
        }
        public void QuickPulseServiceClientPingsTheService()
        {
            // ARRANGE
            string instance = Guid.NewGuid().ToString();
            var timestamp = DateTimeOffset.UtcNow;

            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, instance, string.Empty, new Clock());

            // ACT
            serviceClient.Ping(string.Empty, timestamp);
            serviceClient.Ping(string.Empty, timestamp);
            serviceClient.Ping(string.Empty, timestamp);

            // ASSERT
            Assert.AreEqual(3, this.pingCount);
            Assert.AreEqual(timestamp.DateTime.ToLongTimeString(), this.lastPingTimestamp.Value.DateTime.ToLongTimeString());
            Assert.AreEqual(instance, this.lastPingInstance);
        }
        public void QuickPulseServiceClientSubmitsVersionToServiceWithPing()
        {
            // ARRANGE
            var now = DateTimeOffset.UtcNow;
            var version = "this version";
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, string.Empty, version, new Clock());

            // ACT
            serviceClient.Ping("some ikey", now);

            // ASSERT
            this.listener.Stop();

            Assert.AreEqual(1, this.pingCount);
            Assert.AreEqual(version, this.lastVersion);
        }
        public void QuickPulseServiceClientInterpretsPingResponseCorrectlyWhenHeaderTrue()
        {
            // ARRANGE
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, string.Empty, string.Empty, new Clock());

            // ACT
            this.pingResponse = r => { r.AddHeader("x-ms-qps-subscribed", true.ToString()); };
            bool? response = serviceClient.Ping(string.Empty, DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.IsTrue(response.Value);
        }
        public void QuickPulseServiceClientInterpretsPingResponseCorrectlyWhenHeaderMissing()
        {
            // ARRANGE
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, string.Empty, string.Empty, new Clock());

            // ACT
            this.pingResponse = r => { };
            bool? response = serviceClient.Ping(string.Empty, DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.IsNull(response);
        }
        public void QuickPulseServiceClientSubmitsStreamIdToServiceWithPing()
        {
            // ARRANGE
            var streamId = "this stream";
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, string.Empty, streamId, string.Empty, string.Empty, new Clock(), false);

            // ACT
            serviceClient.Ping(Guid.NewGuid().ToString(), DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.AreEqual(1, this.pings.Count);
            Assert.AreEqual(streamId, this.pings[0].Item2.StreamId);
        }
        public void QuickPulseServiceClientSubmitsInstanceNameToServiceWithPing()
        {
            // ARRANGE
            var instanceName = "this instance";
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, instanceName, instanceName, instanceName, string.Empty, new Clock(), false);

            // ACT
            serviceClient.Ping(Guid.NewGuid().ToString(), DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.AreEqual(1, this.pings.Count);
            Assert.AreEqual(instanceName, this.pings[0].Item2.Instance);
        }
        public void QuickPulseServiceClientInterpretsPingResponseCorrectlyWhenHeaderInvalid()
        {
            // ARRANGE
            var serviceClient = new QuickPulseServiceClient(this.serviceEndpoint, string.Empty, string.Empty, string.Empty, string.Empty, new Clock(), false);

            // ACT
            this.pingResponse = r => { r.AddHeader(QuickPulseConstants.XMsQpsSubscribedHeaderName, "bla"); };
            bool? response = serviceClient.Ping(string.Empty, DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.IsNull(response);
        }