コード例 #1
0
        public void CreateForceUserSignOutRequestThrowsOnNullArguments()
        {
            var requestFactory = new RequestFactory("apiKey", "secretKey", "http://example.com");

            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateForceUserSignOutRequest(null));
            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateForceUserSignOutRequest(string.Empty));
        }
コード例 #2
0
        public void CreateIsUserOnlineRequestReturnsCorrectRequest()
        {
            var baseUrl = "http://example.com";
            var apiKey = "apiKey";
            var secretKey = "secretKey";
            var requestFactory = new RequestFactory(apiKey, secretKey, baseUrl);

            var request = requestFactory.CreateIsUserOnlineRequest("username");

            request.AssertCorrectSecret(secretKey);
            request.AssertCorrectContentType();
            request.AssertCorrectMethod(HttpVerb.GET);
            request.AssertCorrectUrl(baseUrl, apiKey, "users/username");
            Assert.That(string.IsNullOrEmpty(request.Body));
        }
コード例 #3
0
        public void CreateSendMessageToUserRequestThrowsOnNullArguments()
        {
            var requestFactory = new RequestFactory("apiKey", "secretKey", "http://example.com");

            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateSendMessageToUserRequest(null, "message"));
            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateSendMessageToUserRequest(string.Empty, "message"));
            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateSendMessageToUserRequest("username", null));
            Assert.Throws<ArgumentNullException>(() => requestFactory.CreateSendMessageToUserRequest("username", string.Empty));
        }
コード例 #4
0
        public void CreateSendMessageToUserRequestReturnsCorrectRequest()
        {
            var baseUrl = "http://example.com";
            var apiKey = "apiKey";
            var secretKey = "secretKey";
            var requestFactory = new RequestFactory(apiKey, secretKey, baseUrl);

            var request = requestFactory.CreateSendMessageToUserRequest("username", "message");

            request.AssertCorrectSecret(secretKey);
            request.AssertCorrectContentType();
            request.AssertCorrectMethod(HttpVerb.POST);
            request.AssertCorrectUrl(baseUrl, apiKey, "users/username");
            Assert.That(request.Body, Is.EqualTo("message"));
        }