public async Task ShouldPostWithHeader()
        {
            Dictionary <string, string> actual = null;

            _restClientMock.Setup(x => x.PostAsync <JObject>(It.IsAny <Uri>(),
                                                             It.IsAny <HttpContent>(),
                                                             null,
                                                             It.IsAny <Dictionary <string, string> >()))
            .Callback <Uri, HttpContent, string, Dictionary <string, string> >((x, y, z, d) =>
            {
                actual = d;
            })
            .ReturnsAsync(JObject.Parse(Fixtures.FixtureData.SampleAsanaOauthTokenResponse()));

            this._communicator = new AsanaCommunicatorService(_asanaOAuth, _restClient);

            var result = _communicator.PostAsync <JObject>(new Uri("http://any"), null, null, null);

            Assert.IsNotNull(result);
            Assert.IsTrue(actual.ContainsKey("Authorization"));
        }
Ejemplo n.º 2
0
        public async Task <AsanaStory> PostCommentAsync(string taskId, string commentText)
        {
            var uri = new Uri(_asanaParams.StoriesUrl.Replace("{task-id}", taskId));

            try
            {
                var contentDic = new Dictionary <string, string>()
                {
                    { "text", commentText }
                };
                var content = new FormUrlEncodedContent(contentDic);

                var response = await _restClient.PostAsync <JObject>(uri, content).ConfigureAwait(false);

                var result = response.GetValue("data").ToObject <AsanaStory>();
                return(result);
            }
            catch (Exception exp)
            {
                Logger.GetLogger().Error($"terminalAsana error = {exp.Message}");
                throw;
            }
        }