public async Task GetSecretLookupTable_ReturnsSameInstance()
        {
            // Arrange
            Initialize(TestSecret);
            PusherReceiverMock mock = new PusherReceiverMock();

            // Act
            IDictionary <string, string> actual1 = await mock.GetSecretLookupTable(TestId, _postRequest);

            IDictionary <string, string> actual2 = await mock.GetSecretLookupTable(TestId, _postRequest);

            // Assert
            Assert.Same(actual1, actual2);
        }
        public async Task GetSecretLookupTable_BuildsLookupTable(string id, string secret, IDictionary <string, string> expected)
        {
            // Arrange
            Initialize(GetConfigValue(id, secret));
            PusherReceiverMock mock = new PusherReceiverMock();

            // Act
            IDictionary <string, string> actual = await mock.GetSecretLookupTable(id, _postRequest);

            // Assert
            Assert.Equal(expected, actual);
        }
        public async Task GetSecretLookupTable_Throws_IfNoSecrets(string id)
        {
            // Arrange
            Initialize(new string(' ', 32));
            PusherReceiverMock mock = new PusherReceiverMock();

            // Act
            HttpResponseException ex = await Assert.ThrowsAsync <HttpResponseException>(() => mock.GetSecretLookupTable(id, _postRequest));

            // Assert
            HttpError error = await ex.Response.Content.ReadAsAsync <HttpError>();

            string expected = string.Format(CultureInfo.CurrentCulture, "Could not find a valid configuration for WebHook receiver 'pusher' and instance '{0}'. The setting must be set to a value between 8 and 128 characters long.", id);

            Assert.Equal(expected, error.Message);
        }
        public async Task GetSecretLookupTable_Throws_IfInvalidSecret(string id, string invalid)
        {
            // Arrange
            PusherReceiverMock mock = new PusherReceiverMock();

            Initialize(GetConfigValue(id, invalid));

            // Act
            HttpResponseException ex = await Assert.ThrowsAsync <HttpResponseException>(() => mock.GetSecretLookupTable(id, _postRequest));

            // Assert
            HttpError error = await ex.Response.Content.ReadAsAsync <HttpError>();

            Assert.Equal("The application setting for Pusher must be a comma-separated list of segments of the form '<appKey1>_<appSecret1>; <appKey2>_<appSecret2>'.", error.Message);
        }