diff --git a/src/SlackConnector.Tests.Integration/Connections/Clients/FlurlHandshakeClientTests.cs b/src/SlackConnector.Tests.Integration/Connections/Clients/FlurlHandshakeClientTests.cs new file mode 100644 index 0000000..aa13866 --- /dev/null +++ b/src/SlackConnector.Tests.Integration/Connections/Clients/FlurlHandshakeClientTests.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Should; +using SlackConnector.Connections.Clients; +using SlackConnector.Connections.Clients.Handshake; +using SlackConnector.Connections.Responses; +using SlackConnector.Tests.Integration.Configuration; + +namespace SlackConnector.Tests.Integration.Connections.Clients +{ + [TestFixture] + public class FlurlHandshakeClientTests + { + [Test] + public async Task should_perform_handshake_with_flurl() + { + // given + var config = new ConfigReader().GetConfig(); + var client = new FlurlHandshakeClient(new ResponseVerifier()); + + // when + HandshakeResponse response = await client.FirmShake(config.Slack.ApiToken); + + // then + response.ShouldNotBeNull(); + response.WebSocketUrl.ShouldNotBeEmpty(); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Integration/JoinDmChannelTests.cs b/src/SlackConnector.Tests.Integration/JoinDmChannelTests.cs index 0031937..c7bfc26 100644 --- a/src/SlackConnector.Tests.Integration/JoinDmChannelTests.cs +++ b/src/SlackConnector.Tests.Integration/JoinDmChannelTests.cs @@ -33,7 +33,7 @@ public async Task should_join_channel() var dmChannel = connection.ConnectedDM($"@{config.Slack.TestUserName}"); Assert.That(dmChannel, Is.Not.Null); - await connection.Say(new BotMessage{ChatHub = dmChannel, Text = "Wuzzup - testing in da haus"}); + await connection.Say(new BotMessage { ChatHub = dmChannel, Text = "Wuzzup - testing in da haus" }); } } } \ No newline at end of file diff --git a/src/SlackConnector.Tests.Integration/SlackConnector.Tests.Integration.csproj b/src/SlackConnector.Tests.Integration/SlackConnector.Tests.Integration.csproj index b6c3926..ff4df6f 100644 --- a/src/SlackConnector.Tests.Integration/SlackConnector.Tests.Integration.csproj +++ b/src/SlackConnector.Tests.Integration/SlackConnector.Tests.Integration.csproj @@ -9,7 +9,7 @@ Properties SlackConnector.Tests.Integration SlackConnector.Tests.Integration - v4.6 + v4.6.1 512 @@ -32,21 +32,76 @@ 4 - - ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\..\packages\Flurl.2.2.1\lib\netstandard1.4\Flurl.dll + True + + + ..\..\packages\Flurl.Http.1.1.1\lib\net45\Flurl.Http.dll + True + + + ..\..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll + True + + + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll True + + ..\..\packages\Should.1.1.20\lib\Should.dll + True + + + ..\..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + True + + + ..\..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll + True + + + ..\..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + ..\..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll + True + + + ..\..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net46\System.Reflection.TypeExtensions.dll + True + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll + True + + + ..\..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + + + ..\..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + + + ..\..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll + True + - @@ -54,6 +109,7 @@ + diff --git a/src/SlackConnector.Tests.Integration/app.config b/src/SlackConnector.Tests.Integration/app.config index 1eb16eb..72c1eb0 100644 --- a/src/SlackConnector.Tests.Integration/app.config +++ b/src/SlackConnector.Tests.Integration/app.config @@ -1,11 +1,23 @@ - + - - + + + + + + + + + + + + + + - + diff --git a/src/SlackConnector.Tests.Integration/packages.config b/src/SlackConnector.Tests.Integration/packages.config index d53d77b..6ac7c00 100644 --- a/src/SlackConnector.Tests.Integration/packages.config +++ b/src/SlackConnector.Tests.Integration/packages.config @@ -1,5 +1,20 @@  - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/ChannelClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/ChannelClientTests.cs deleted file mode 100644 index f024f54..0000000 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/ChannelClientTests.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Linq; -using NUnit.Framework; -using RestSharp; -using Should; -using SlackConnector.Connections.Clients.Channel; -using SlackConnector.Connections.Models; -using SlackConnector.Connections.Responses; -using SlackConnector.Tests.Unit.Stubs; -using SpecsFor; - -namespace SlackConnector.Tests.Unit.Connections.Clients -{ - public static class ChannelClientTests - { - internal class given_valid_standard_setup : SpecsFor - { - private string _slackKey = "super-key"; - private string _user = "super-user"; - private RequestExecutorStub _requestExecutorStub; - private JoinChannelResponse _executorResponse; - private Channel Result { get; set; } - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new ChannelClient(_requestExecutorStub); - } - - protected override void Given() - { - _executorResponse = new JoinChannelResponse - { - Channel = new Channel() - }; - _requestExecutorStub.Execute_Value = _executorResponse; - } - - protected override void When() - { - Result = SUT.JoinDirectMessageChannel(_slackKey, _user).Result; - } - - [Test] - public void then_should_pass_expected_key() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("token")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_slackKey); - } - - [Test] - public void then_should_pass_expected_channel() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("user")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_user); - } - - [Test] - public void then_should_access_expected_path() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Resource.ShouldEqual(ChannelClient.JOIN_DM_PATH); - } - - [Test] - public void then_should_have_2_params() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Parameters.Count.ShouldEqual(2); - } - - [Test] - public void then_should_return_expected_channel() - { - Result.ShouldEqual(_executorResponse.Channel); - } - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/ChatClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/ChatClientTests.cs deleted file mode 100644 index 17841cc..0000000 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/ChatClientTests.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using NUnit.Framework; -using RestSharp; -using Should; -using SlackConnector.Connections.Clients.Chat; -using SlackConnector.Connections.Responses; -using SlackConnector.Models; -using SlackConnector.Tests.Unit.Stubs; -using SpecsFor; - -namespace SlackConnector.Tests.Unit.Connections.Clients -{ - public static class ChatClientTests - { - internal class given_valid_standard_setup_when_posting_message_without_attachments : SpecsFor - { - private string _slackKey = "super-key"; - private string _channel = "super-channel"; - private string _text = "boom-jiggy-boom"; - private RequestExecutorStub _requestExecutorStub; - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new ChatClient(_requestExecutorStub); - } - - protected override void Given() - { - _requestExecutorStub.Execute_Value = new StandardResponse(); - } - - protected override void When() - { - SUT.PostMessage(_slackKey, _channel, _text, null).Wait(); - } - - [Test] - public void then_should_pass_expected_key() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("token")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_slackKey); - } - - [Test] - public void then_should_pass_expected_channel() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("channel")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_channel); - } - - [Test] - public void then_should_pass_expected_text() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("text")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_text); - } - - [Test] - public void then_should_pass_expected_user_param() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("as_user")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual("true"); - } - - [Test] - public void then_should_access_expected_path() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Resource.ShouldEqual(ChatClient.SEND_MESSAGE_PATH); - } - - [Test] - public void then_should_have_4_params() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Parameters.Count.ShouldEqual(4); - } - } - - internal class given_valid_standard_setup_when_posting_message_with_attachments : SpecsFor - { - private List _attachments; - private RequestExecutorStub _requestExecutorStub; - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new ChatClient(_requestExecutorStub); - } - - protected override void Given() - { - _attachments = new List - { - new SlackAttachment - { - Text = "Some Text", - Title = "Some Title" - } - }; - } - - protected override void When() - { - SUT.PostMessage(null, null, null, _attachments).Wait(); - } - - [Test] - public void then_should_pass_expected_text() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter attachments = request.Parameters.FirstOrDefault(x => x.Name.Equals("attachments")); - attachments.ShouldNotBeNull(); - attachments.Type.ShouldEqual(ParameterType.GetOrPost); - - string attachmentsJson = attachments.Value as string; - attachmentsJson.ShouldEqual(JsonConvert.SerializeObject(_attachments)); - } - - [Test] - public void then_should_have_5_params() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Parameters.Count.ShouldEqual(5); - } - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/FileClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/FileClientTests.cs deleted file mode 100644 index db8528d..0000000 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/FileClientTests.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; -using RestSharp; -using Should; -using SlackConnector.Connections.Clients.File; -using SlackConnector.Tests.Unit.Stubs; -using SpecsFor; - -namespace SlackConnector.Tests.Unit.Connections.Clients -{ - public static class FileClientTests - { - internal class given_valid_standard_setup_when_posting_file : SpecsFor - { - private readonly string _slackKey = "super-key"; - private readonly string _channelId = "channel-id"; - private readonly string _filePath = Path.GetTempFileName(); - private RequestExecutorStub _requestExecutorStub; - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new FileClient(_requestExecutorStub); - } - - protected override void Given() - { - File.WriteAllText(_filePath, "test-data"); - } - - protected override void When() - { - SUT.PostFile(_slackKey, _channelId, _filePath).Wait(); - } - - [Test] - public void then_should_pass_expected_key() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("token")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_slackKey); - } - - [Test] - public void then_should_pass_expected_channel() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("channels")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_channelId); - } - - [Test] - public void then_should_access_expected_path() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Resource.ShouldEqual(FileClient.FILE_UPLOAD_PATH); - } - - [Test] - public void then_should_have_3_params() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Parameters.Count.ShouldEqual(3); - } - - [Test] - public void then_should_pass_expected_filename() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("filename")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(Path.GetFileName(_filePath)); - } - - [Test] - public void then_should_pass_expected_file() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - FileParameter file = request.Files.FirstOrDefault(x => x.Name.Equals("file")); - file.ShouldNotBeNull(); - file.ContentLength.ShouldBeGreaterThan(0); - file.FileName.ShouldEqual(Path.GetFileName(_filePath)); - } - } - - internal class given_valid_standard_setup_when_posting_stream : SpecsFor - { - private readonly string _slackKey = "super-key"; - private readonly string _channelId = "channel-id"; - private readonly string _fileName = "file-name.txt"; - private MemoryStream _inputStream; - private RequestExecutorStub _requestExecutorStub; - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new FileClient(_requestExecutorStub); - } - - protected override void Given() - { - _inputStream = new MemoryStream(); - using (var writer = new StreamWriter(_inputStream, Encoding.UTF8)) - { - writer.WriteLine("Some test value - yay :-)"); - } - } - - protected override void When() - { - SUT.PostFile(_slackKey, _channelId, _inputStream, _fileName).Wait(); - } - - [Test] - public void then_should_pass_expected_key() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("token")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_slackKey); - } - - [Test] - public void then_should_pass_expected_channel() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("channels")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(_channelId); - } - - [Test] - public void then_should_access_expected_path() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Resource.ShouldEqual(FileClient.FILE_UPLOAD_PATH); - } - - [Test] - public void then_should_have_3_params() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Parameters.Count.ShouldEqual(3); - } - - [Test] - public void then_should_pass_expected_filename() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("filename")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(Path.GetFileName(_fileName)); - } - - [Test] - public void then_should_pass_expected_file() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - FileParameter file = request.Files.FirstOrDefault(x => x.Name.Equals("file")); - file.ShouldNotBeNull(); - file.ContentLength.ShouldBeGreaterThan(0); - file.FileName.ShouldEqual(Path.GetFileName(_fileName)); - } - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChannelClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChannelClientTests.cs new file mode 100644 index 0000000..47a9243 --- /dev/null +++ b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChannelClientTests.cs @@ -0,0 +1,159 @@ +using System.Threading.Tasks; +using ExpectedObjects; +using Flurl; +using Flurl.Http.Testing; +using Moq; +using NUnit.Framework; +using SlackConnector.Connections.Clients; +using SlackConnector.Connections.Clients.Channel; +using SlackConnector.Connections.Models; +using SlackConnector.Connections.Responses; +using SlackConnector.Tests.Unit.TestExtensions; + +namespace SlackConnector.Tests.Unit.Connections.Clients.Flurl +{ + [TestFixture] + public class FlurlChannelClientTests + { + private HttpTest _httpTest; + private Mock _responseVerifierMock; + private FlurlChannelClient _channelClient; + + [SetUp] + public void Setup() + { + _httpTest = new HttpTest(); + _responseVerifierMock = new Mock(); + _channelClient = new FlurlChannelClient(_responseVerifierMock.Object); + } + + [TearDown] + public void TearDown() + { + _httpTest.Dispose(); + } + + [Test] + public async Task should_join_direct_message_channel() + { + // given + const string slackKey = "I-is-another-key"; + const string userId = "blahdy-blah"; + + var expectedResponse = new JoinChannelResponse + { + Channel = new Channel + { + Id = "some-channel", + IsChannel = true + } + }; + + _httpTest.RespondWithJson(expectedResponse); + + // when + var result = await _channelClient.JoinDirectMessageChannel(slackKey, userId); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse)), Times.Once); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChannelClient.JOIN_DM_PATH)) + .WithQueryParamValue("token", slackKey) + .WithQueryParamValue("user", userId) + .Times(1); + + result.ToExpectedObject().ShouldEqual(expectedResponse.Channel); + } + + [Test] + public async Task should_call_expected_url_and_return_expected_channels() + { + // given + const string slackKey = "I-is-da-key-yeah"; + + var expectedResponse = new ChannelsResponse + { + Channels = new[] + { + new Channel { IsChannel = true, Name = "name1" }, + new Channel { IsArchived = true, Name = "name2" }, + } + }; + + _httpTest.RespondWithJson(expectedResponse); + + // when + var result = await _channelClient.GetChannels(slackKey); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse)), Times.Once); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChannelClient.CHANNELS_LIST_PATH)) + .WithQueryParamValue("token", slackKey) + .Times(1); + + result.ToExpectedObject().ShouldEqual(expectedResponse.Channels); + } + + [Test] + public async Task should_call_expected_url_and_return_expected_groups() + { + // given + const string slackKey = "I-is-another-key"; + + var expectedResponse = new GroupsResponse + { + Groups = new[] + { + new Group { IsGroup = true, Name = "name1" }, + new Group { IsOpen = true, Name = "name2" } + } + }; + + _httpTest.RespondWithJson(expectedResponse); + + // when + var result = await _channelClient.GetGroups(slackKey); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse)), Times.Once); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChannelClient.GROUPS_LIST_PATH)) + .WithQueryParamValue("token", slackKey) + .Times(1); + + result.ToExpectedObject().ShouldEqual(expectedResponse.Groups); + } + + [Test] + public async Task should_call_expected_url_and_return_expected_users() + { + // given + const string slackKey = "I-is-another-key"; + + var expectedResponse = new UsersResponse + { + Members = new[] + { + new User { Id = "some-id-thing", IsBot = true }, + new User { Name = "some-id-thing", Deleted = true }, + } + }; + + _httpTest.RespondWithJson(expectedResponse); + + // when + var result = await _channelClient.GetUsers(slackKey); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse)), Times.Once); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChannelClient.USERS_LIST_PATH)) + .WithQueryParamValue("token", slackKey) + .WithQueryParamValue("presence", "1") + .Times(1); + + result.ToExpectedObject().ShouldEqual(expectedResponse.Members); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChatClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChatClientTests.cs new file mode 100644 index 0000000..dba5b33 --- /dev/null +++ b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlChatClientTests.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Flurl; +using Flurl.Http.Testing; +using Moq; +using Newtonsoft.Json; +using NUnit.Framework; +using SlackConnector.Connections.Clients; +using SlackConnector.Connections.Clients.Chat; +using SlackConnector.Connections.Responses; +using SlackConnector.Models; +using SlackConnector.Tests.Unit.TestExtensions; + +namespace SlackConnector.Tests.Unit.Connections.Clients.Flurl +{ + [TestFixture] + public class FlurlChatClientTests + { + private HttpTest _httpTest; + private Mock _responseVerifierMock; + private FlurlChatClient _chatClient; + + [SetUp] + public void Setup() + { + _httpTest = new HttpTest(); + _responseVerifierMock = new Mock(); + _chatClient = new FlurlChatClient(_responseVerifierMock.Object); + } + + [TearDown] + public void TearDown() + { + _httpTest.Dispose(); + } + + [Test] + public async Task should_call_expected_url_with_given_slack_key() + { + // given + const string slackKey = "something-that-looks-like-a-slack-key"; + const string channel = "channel-name"; + const string text = "some-text-for-you"; + + var expectedResponse = new StandardResponse(); + _httpTest.RespondWithJson(expectedResponse); + + // when + await _chatClient.PostMessage(slackKey, channel, text, null); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse))); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChatClient.SEND_MESSAGE_PATH)) + .WithQueryParamValue("token", slackKey) + .WithQueryParamValue("channel", channel) + .WithQueryParamValue("text", text) + .WithQueryParamValue("as_user", "true") + .WithoutQueryParam("attachments") + .Times(1); + } + + [Test] + public async Task should_add_attachments_if_given() + { + // given + _httpTest.RespondWithJson(new StandardResponse()); + var attachments = new List + { + new SlackAttachment { Text = "dummy text" }, + new SlackAttachment { AuthorName = "dummy author" }, + }; + + // when + await _chatClient.PostMessage(It.IsAny(), It.IsAny(), It.IsAny(), attachments); + + // then + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChatClient.SEND_MESSAGE_PATH)) + .WithQueryParamValue("attachments", JsonConvert.SerializeObject(attachments)) + .Times(1); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlFileClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlFileClientTests.cs new file mode 100644 index 0000000..b7226c4 --- /dev/null +++ b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlFileClientTests.cs @@ -0,0 +1,62 @@ +using System.Net.Http; +using System.Threading.Tasks; +using Flurl; +using Flurl.Http.Testing; +using Moq; +using NUnit.Framework; +using SlackConnector.Connections.Clients; +using SlackConnector.Connections.Clients.Channel; +using SlackConnector.Connections.Clients.Chat; +using SlackConnector.Connections.Clients.File; +using SlackConnector.Connections.Responses; +using SlackConnector.Tests.Unit.TestExtensions; + +namespace SlackConnector.Tests.Unit.Connections.Clients.Flurl +{ + [TestFixture] + public class FlurlFileClientTests + { + private HttpTest _httpTest; + private Mock _responseVerifierMock; + private FlurlFileClient _fileClient; + + [SetUp] + public void Setup() + { + _httpTest = new HttpTest(); + _responseVerifierMock = new Mock(); + _fileClient = new FlurlFileClient(_responseVerifierMock.Object); + } + + [TearDown] + public void TearDown() + { + _httpTest.Dispose(); + } + + [Test] + public async Task should_call_expected_url_with_given_slack_key() + { + // given + const string slackKey = "something-that-looks-like-a-slack-key"; + const string channel = "channel-name"; + const string filePath = @"C:\test-file-name.exe"; + + var expectedResponse = new StandardResponse(); + _httpTest.RespondWithJson(expectedResponse); + + // when + await _fileClient.PostFile(slackKey, channel, filePath); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse))); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlFileClient.FILE_UPLOAD_PATH)) + .WithQueryParamValue("token", slackKey) + .WithQueryParamValue("channels", channel) + .WithVerb(HttpMethod.Post) + .WithContentType("multipart/form-data") + .Times(1); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlHandshakeClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlHandshakeClientTests.cs new file mode 100644 index 0000000..46b9e75 --- /dev/null +++ b/src/SlackConnector.Tests.Unit/Connections/Clients/Flurl/FlurlHandshakeClientTests.cs @@ -0,0 +1,61 @@ +using System.Threading.Tasks; +using ExpectedObjects; +using Flurl; +using Flurl.Http.Testing; +using Moq; +using NUnit.Framework; +using SlackConnector.Connections.Clients; +using SlackConnector.Connections.Clients.Handshake; +using SlackConnector.Connections.Responses; +using SlackConnector.Tests.Unit.TestExtensions; + +namespace SlackConnector.Tests.Unit.Connections.Clients.Flurl +{ + [TestFixture] + public class FlurlHandshakeClientTests + { + private HttpTest _httpTest; + private Mock _responseVerifierMock; + private FlurlHandshakeClient _handshakeClient; + + [SetUp] + public void Setup() + { + _httpTest = new HttpTest(); + _responseVerifierMock = new Mock(); + _handshakeClient = new FlurlHandshakeClient(_responseVerifierMock.Object); + } + + [TearDown] + public void TearDown() + { + _httpTest.Dispose(); + } + + [Test] + public async Task should_call_expected_url_with_given_slack_key() + { + // given + const string slackKey = "I-is-da-key-yeah"; + + var expectedResponse = new HandshakeResponse + { + Ok = true, + WebSocketUrl = "some-url" + }; + _httpTest.RespondWithJson(expectedResponse); + + // when + var result = await _handshakeClient.FirmShake(slackKey); + + // then + _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse))); + _httpTest + .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlHandshakeClient.HANDSHAKE_PATH)) + .WithQueryParamValue("token", slackKey) + .Times(1); + + result.ToExpectedObject().ShouldEqual(expectedResponse); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/HandshakeClientTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/HandshakeClientTests.cs deleted file mode 100644 index 7c4898a..0000000 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/HandshakeClientTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Linq; -using NUnit.Framework; -using RestSharp; -using Should; -using SlackConnector.Connections.Clients.Handshake; -using SlackConnector.Connections.Responses; -using SlackConnector.Tests.Unit.Stubs; -using SpecsFor; - -namespace SlackConnector.Tests.Unit.Connections.Clients -{ - public static class HandshakeClientTests - { - internal class given_valid_response_when_handshaking_with_slack : SpecsFor - { - private const string SLACK_KEY = "something_that_looks_like_a_key"; - private RequestExecutorStub _requestExecutorStub; - private HandshakeResponse Result { get; set; } - - protected override void InitializeClassUnderTest() - { - _requestExecutorStub = new RequestExecutorStub(); - SUT = new HandshakeClient(_requestExecutorStub); - } - - protected override void Given() - { - _requestExecutorStub.Execute_Value = new HandshakeResponse(); - } - - protected override void When() - { - Result = SUT.FirmShake(SLACK_KEY).Result; - } - - [Test] - public void then_should_pass_expected_key() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - Parameter keyParam = request.Parameters.FirstOrDefault(x => x.Name.Equals("token")); - keyParam.ShouldNotBeNull(); - keyParam.Type.ShouldEqual(ParameterType.GetOrPost); - keyParam.Value.ShouldEqual(SLACK_KEY); - } - - [Test] - public void then_should_access_expected_path() - { - IRestRequest request = _requestExecutorStub.Execute_Request; - request.Resource.ShouldEqual(HandshakeClient.HANDSHAKE_PATH); - } - - [Test] - public void then_should_return_expected_model() - { - Result.ShouldEqual(_requestExecutorStub.Execute_Value); - } - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/RequestExecutorTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/RequestExecutorTests.cs deleted file mode 100644 index 000e0d9..0000000 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/RequestExecutorTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Moq; -using NUnit.Framework; -using RestSharp; -using Should; -using SlackConnector.Connections; -using SlackConnector.Connections.Clients; -using SlackConnector.Connections.Responses; -using SpecsFor; - -namespace SlackConnector.Tests.Unit.Connections.Clients -{ - public static class RequestExecutorTests - { - internal class given_request_when_executing : SpecsFor - { - private IRestRequest _request; - private IRestResponse _response; - private ExampleResponse _expectedResult; - private ExampleResponse Result { get; set; } - - protected override void Given() - { - _request = new RestRequest(); - _response = new RestResponse(); - - GetMockFor() - .Setup(x => x.CreateClient(RequestExecutor.SLACK_URL)) - .Returns(GetMockFor().Object); - - GetMockFor() - .Setup(x => x.ExecutePostTaskAsync(_request)) - .ReturnsAsync(_response); - - _expectedResult = new ExampleResponse(); - GetMockFor() - .Setup(x => x.VerifyResponse(_response)) - .Returns(_expectedResult); - } - - protected override void When() - { - Result = SUT.Execute(_request).Result; - } - - [Test] - public void then_should_return_expected_result() - { - Result.ShouldEqual(_expectedResult); - } - } - - private class ExampleResponse : StandardResponse - { - - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Connections/Clients/ResponseVerifierTests.cs b/src/SlackConnector.Tests.Unit/Connections/Clients/ResponseVerifierTests.cs index bf623b6..163e9f9 100644 --- a/src/SlackConnector.Tests.Unit/Connections/Clients/ResponseVerifierTests.cs +++ b/src/SlackConnector.Tests.Unit/Connections/Clients/ResponseVerifierTests.cs @@ -1,258 +1,35 @@ -using System.Net; -using NUnit.Framework; -using RestSharp; +using NUnit.Framework; using Should; using SlackConnector.Connections.Clients; -using SlackConnector.Connections.Models; using SlackConnector.Connections.Responses; using SlackConnector.Exceptions; -using SpecsFor; -using SpecsFor.ShouldExtensions; namespace SlackConnector.Tests.Unit.Connections.Clients { - public static class ResponseVerifierTests + [TestFixture] + public class ResponseVerifierTests { - internal class given_valid_response_then_should_return_expected_object : SpecsFor + [Test] + public void should_throw_exception_with_given_error_message_when_request_failed() { - private IRestResponse restResponse; - private ExampleModel Result { get; set; } + // given + var response = new StandardResponse { Ok = false, Error = "I AM A ERROR-message" }; + var verifier = new ResponseVerifier(); - protected override void Given() - { - restResponse = new RestResponse - { - StatusCode = HttpStatusCode.OK, - Content = @"{'ok': true, 'value': 'test'}" - }; - } - - protected override void When() - { - Result = SUT.VerifyResponse(restResponse); - } - - [Test] - public void then_should_return_expected_model() - { - var expected = new ExampleModel - { - Ok = true, - Value = "test" - }; - Result.ShouldLookLike(expected); - } - } - - internal class given_invalid_http_response_then_should_throw_exception : SpecsFor - { - private IRestResponse restResponse; - - protected override void Given() - { - restResponse = new RestResponse - { - StatusCode = HttpStatusCode.BadRequest - }; - } - - - [Test] - public void then_should_throw_expected_exception() - { - CommunicationException exception = null; - - try - { - SUT.VerifyResponse(restResponse); - } - catch (CommunicationException ex) - { - exception = ex; - } - - string expectedMessage = $"Error occured while sending message '{restResponse.StatusCode}'"; - exception.ShouldNotBeNull(); - exception.Message.ShouldEqual(expectedMessage); - } - } - - internal class given_error_in_response_json_then_should_throw_exception : SpecsFor - { - private IRestResponse restResponse; - - protected override void Given() - { - restResponse = new RestResponse - { - StatusCode = HttpStatusCode.OK, - Content = @"{'ok': false, 'error': 'test error'}" - }; - } - - - [Test] - public void then_should_throw_expected_exception() - { - CommunicationException exception = null; - - try - { - SUT.VerifyResponse(restResponse); - } - catch (CommunicationException ex) - { - exception = ex; - } - - exception.ShouldNotBeNull(); - exception.Message.ShouldEqual("Error occured while posting message 'test error'"); - } + // when && then + var exception = Assert.Throws(() => verifier.VerifyResponse(response)); + exception.Message.ShouldEqual($"Error occured while posting message '{response.Error}'"); } - internal class given_join_channel_response : SpecsFor + [Test] + public void should_not_throw_exception() { - private IRestResponse _restResponse; - private JoinChannelResponse Result { get; set; } - - protected override void Given() - { - _restResponse = new RestResponse - { - StatusCode = HttpStatusCode.OK, - Content = @"{ - 'ok':true, - 'channel': { - 'id': 'my-id', - 'name': 'my-name', - } - }" - }; - } - - protected override void When() - { - Result = SUT.VerifyResponse(_restResponse); - } + // given + var response = new StandardResponse { Ok = true }; + var verifier = new ResponseVerifier(); - [Test] - public void should_return_expected_channel_response() - { - var expected = new JoinChannelResponse - { - Ok = true, - Error = null, - Channel = new Channel - { - Id = "my-id", - Name = "my-name" - } - }; - - Result.ShouldLookLike(expected); - } - } - - internal class given_handshake_response : SpecsFor - { - private IRestResponse _restResponse; - private HandshakeResponse Result { get; set; } - - protected override void Given() - { - _restResponse = new RestResponse - { - StatusCode = HttpStatusCode.OK, - Content = Resources.ResourceManager.GetHandShakeResponseJson() - }; - } - - protected override void When() - { - Result = SUT.VerifyResponse(_restResponse); - } - - [Test] - public void should_return_expected_channel_response() - { - var expected = new HandshakeResponse - { - Ok = true, - Self = new Detail - { - Id = "self-id", - Name = "self-name" - }, - Team = new Detail - { - Id = "team-id", - Name = "team-name" - }, - Channels = new[] - { - new Channel - { - Id = "channel-id", - Name = "channel-name", - IsChannel = true, - IsArchived = true, - IsMember = true - } - }, - Groups = new[] - { - new Group - { - Id = "group-id", - Name = "group-name", - IsGroup = true, - IsArchived = true, - IsOpen = true, - Members = new [] - { - "member1" - } - } - }, - Ims = new[] - { - new Im - { - Id = "im-id", - User = "im-user", - IsIm = true, - IsOpen = true - } - }, - Users = new[] - { - new User - { - Id = "user-id", - Name = "user-name", - Deleted = true, - Profile = new Profile - { - FirstName = "first-name", - LastName = "last-name", - RealName = "real-name", - RealNameNormalised = "real-name-normalized", - Email = "email" - }, - IsAdmin = true, - IsBot = true - } - }, - WebSocketUrl = @"wss://ms331.slack-msgs.com/websocket/999" - }; - - Result.ShouldLookLike(expected); - } - } - - private class ExampleModel : StandardResponse - { - public string Value { get; set; } + // when && then + Assert.DoesNotThrow(() => verifier.VerifyResponse(response)); } } } \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/SlackConnector.Tests.Unit.csproj b/src/SlackConnector.Tests.Unit/SlackConnector.Tests.Unit.csproj index a849d5b..efd2d22 100644 --- a/src/SlackConnector.Tests.Unit/SlackConnector.Tests.Unit.csproj +++ b/src/SlackConnector.Tests.Unit/SlackConnector.Tests.Unit.csproj @@ -9,7 +9,7 @@ Properties SlackConnector.Tests.Unit SlackConnector.Tests.Unit - v4.6 + v4.6.1 512 @@ -36,12 +36,24 @@ ..\..\packages\ExpectedObjects.1.2.3\lib\net40\ExpectedObjects.dll True + + ..\..\packages\Flurl.2.2.1\lib\netstandard1.4\Flurl.dll + True + + + ..\..\packages\Flurl.Http.1.1.1\lib\net45\Flurl.Http.dll + True + + + ..\..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll + True + ..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll True - - ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True @@ -64,10 +76,6 @@ ..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll False - - ..\..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll - True - ..\..\packages\Should.1.1.20\lib\Should.dll True @@ -90,21 +98,59 @@ + + ..\..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + True + + + ..\..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll + True + + + ..\..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + ..\..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll + True + + + ..\..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net46\System.Reflection.TypeExtensions.dll + True + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll + True + + + ..\..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + + + ..\..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + + + ..\..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll + True + - - - - - - + + + + @@ -128,11 +174,10 @@ - - + diff --git a/src/SlackConnector.Tests.Unit/Stubs/RequestExecutorStub.cs b/src/SlackConnector.Tests.Unit/Stubs/RequestExecutorStub.cs deleted file mode 100644 index efd6f68..0000000 --- a/src/SlackConnector.Tests.Unit/Stubs/RequestExecutorStub.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Threading.Tasks; -using RestSharp; -using SlackConnector.Connections.Clients; -using SlackConnector.Connections.Responses; - -namespace SlackConnector.Tests.Unit.Stubs -{ - internal class RequestExecutorStub : IRequestExecutor - { - public IRestRequest Execute_Request { get; private set; } - public StandardResponse Execute_Value { get; set; } - - public Task Execute(IRestRequest request) where T : class - { - Execute_Request = request; - return Task.FromResult(Execute_Value as T); - } - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/Stubs/RestClientStub.cs b/src/SlackConnector.Tests.Unit/Stubs/RestClientStub.cs deleted file mode 100644 index ac1fa36..0000000 --- a/src/SlackConnector.Tests.Unit/Stubs/RestClientStub.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Cache; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using RestSharp; -using RestSharp.Authenticators; -using RestSharp.Deserializers; - -namespace SlackConnector.Tests.Unit.Stubs -{ - public class RestClientStub : IRestClient - { - public string ExecutePostTaskAsync_Content { get; set; } - public HttpStatusCode ExecutePostTaskAsync_StatusCode { get; set; } - public IRestRequest ExecutePostTaskAsync_Request { get; private set; } - public IRestResponse ExecutePostTaskAsync_Response { get; set; } - public async Task ExecutePostTaskAsync(IRestRequest request) - { - ExecutePostTaskAsync_Request = request; - - var response = ExecutePostTaskAsync_Response ?? new RestResponse - { - Content = ExecutePostTaskAsync_Content, - StatusCode = ExecutePostTaskAsync_StatusCode - }; - - return await Task.FromResult(response); - } - - #region Not Implemented - - public RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action callback) - { - throw new NotImplementedException(); - } - - public RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action, RestRequestAsyncHandle> callback) - { - throw new NotImplementedException(); - } - - public IRestResponse Execute(IRestRequest request) - { - throw new NotImplementedException(); - } - - public IRestResponse Execute(IRestRequest request) where T : new() - { - throw new NotImplementedException(); - } - - public byte[] DownloadData(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Uri BuildUri(IRestRequest request) - { - throw new NotImplementedException(); - } - - public RestRequestAsyncHandle ExecuteAsyncGet(IRestRequest request, Action callback, string httpMethod) - { - throw new NotImplementedException(); - } - - public RestRequestAsyncHandle ExecuteAsyncPost(IRestRequest request, Action callback, string httpMethod) - { - throw new NotImplementedException(); - } - - public RestRequestAsyncHandle ExecuteAsyncGet(IRestRequest request, Action, RestRequestAsyncHandle> callback, string httpMethod) - { - throw new NotImplementedException(); - } - - public RestRequestAsyncHandle ExecuteAsyncPost(IRestRequest request, Action, RestRequestAsyncHandle> callback, string httpMethod) - { - throw new NotImplementedException(); - } - - public void AddHandler(string contentType, IDeserializer deserializer) - { - throw new NotImplementedException(); - } - - public void RemoveHandler(string contentType) - { - throw new NotImplementedException(); - } - - public void ClearHandlers() - { - throw new NotImplementedException(); - } - - public IRestResponse ExecuteAsGet(IRestRequest request, string httpMethod) - { - throw new NotImplementedException(); - } - - public IRestResponse ExecuteAsPost(IRestRequest request, string httpMethod) - { - throw new NotImplementedException(); - } - - public IRestResponse ExecuteAsGet(IRestRequest request, string httpMethod) where T : new() - { - throw new NotImplementedException(); - } - - public IRestResponse ExecuteAsPost(IRestRequest request, string httpMethod) where T : new() - { - throw new NotImplementedException(); - } - - public Task> ExecuteTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public Task> ExecuteTaskAsync(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Task> ExecuteGetTaskAsync(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Task> ExecuteGetTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public Task> ExecutePostTaskAsync(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Task> ExecutePostTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public Task ExecuteTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public Task ExecuteTaskAsync(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Task ExecuteGetTaskAsync(IRestRequest request) - { - throw new NotImplementedException(); - } - - public Task ExecuteGetTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public Task ExecutePostTaskAsync(IRestRequest request, CancellationToken token) - { - throw new NotImplementedException(); - } - - public CookieContainer CookieContainer { get; set; } - public int? MaxRedirects { get; set; } - public string UserAgent { get; set; } - public int Timeout { get; set; } - public int ReadWriteTimeout { get; set; } - public bool UseSynchronizationContext { get; set; } - public IAuthenticator Authenticator { get; set; } - public Uri BaseUrl { get; set; } - public Encoding Encoding { get; set; } - public bool PreAuthenticate { get; set; } - public IList DefaultParameters { get; } - public X509CertificateCollection ClientCertificates { get; set; } - public IWebProxy Proxy { get; set; } - public RequestCachePolicy CachePolicy { get; set; } - public bool FollowRedirects { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/TestExtensions/ShouldExtensions.cs b/src/SlackConnector.Tests.Unit/TestExtensions/ShouldExtensions.cs new file mode 100644 index 0000000..dad3586 --- /dev/null +++ b/src/SlackConnector.Tests.Unit/TestExtensions/ShouldExtensions.cs @@ -0,0 +1,57 @@ +using System; +using System.Linq.Expressions; +using ExpectedObjects; +using Moq; +using SpecsFor.ShouldExtensions; + +namespace SlackConnector.Tests.Unit.TestExtensions +{ + public static class Looks + { + public static T Like(T obj) + { + var expected = obj.ToExpectedObject(); + return It.Is(t => expected.Equals(t)); + } + + public static T Like(Expression> initializer) where T : class + { + return It.Is(t => ShouldMatch(initializer, t)); + } + + + public static T LikePartialOf(object partial) + { + var expected = partial.ToExpectedObject(); + + return It.Is(t => ShouldMatch(expected, t)); + } + + private static bool ShouldMatch(Expression> initializer, T o) where T : class + { + try + { + o.ShouldLookLike(initializer); + } + catch (Exception) + { + return false; + } + + return true; + } + + private static bool ShouldMatch(ExpectedObject expected, object o) + { + try + { + expected.ShouldMatch(o); + return true; + } + catch (Exception) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/src/SlackConnector.Tests.Unit/app.config b/src/SlackConnector.Tests.Unit/app.config index 89f8eb0..17e277f 100644 --- a/src/SlackConnector.Tests.Unit/app.config +++ b/src/SlackConnector.Tests.Unit/app.config @@ -6,6 +6,18 @@ + + + + + + + + + + + + - + diff --git a/src/SlackConnector.Tests.Unit/packages.config b/src/SlackConnector.Tests.Unit/packages.config index 0ca52ea..27b431e 100644 --- a/src/SlackConnector.Tests.Unit/packages.config +++ b/src/SlackConnector.Tests.Unit/packages.config @@ -1,13 +1,27 @@  - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Channel/ChannelClient.cs b/src/SlackConnector/Connections/Clients/Channel/ChannelClient.cs deleted file mode 100644 index f74394b..0000000 --- a/src/SlackConnector/Connections/Clients/Channel/ChannelClient.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Threading.Tasks; -using RestSharp; -using SlackConnector.Connections.Models; -using SlackConnector.Connections.Responses; - -namespace SlackConnector.Connections.Clients.Channel -{ - internal class ChannelClient : IChannelClient - { - internal const string JOIN_DM_PATH = "/api/im.open"; - internal const string CHANNELS_LIST_PATH = "/api/channels.list"; - internal const string GROUPS_LIST_PATH = "/api/groups.list"; - internal const string USERS_LIST_PATH = "/api/users.list"; - private readonly IRequestExecutor _requestExecutor; - - public ChannelClient(IRequestExecutor requestExecutor) - { - _requestExecutor = requestExecutor; - } - - public async Task JoinDirectMessageChannel(string slackKey, string user) - { - var request = new RestRequest(JOIN_DM_PATH); - request.AddParameter("token", slackKey); - request.AddParameter("user", user); - - var response = await _requestExecutor.Execute(request); - return response.Channel; - } - - public async Task GetChannels(string slackKey) - { - var request = new RestRequest(CHANNELS_LIST_PATH); - request.AddParameter("token", slackKey); - - var response = await _requestExecutor.Execute(request); - return response.Channels; - } - - public async Task GetGroups(string slackKey) - { - var request = new RestRequest(GROUPS_LIST_PATH); - request.AddParameter("token", slackKey); - - var response = await _requestExecutor.Execute(request); - return response.Groups; - } - - public async Task GetUsers(string slackKey) - { - var request = new RestRequest(USERS_LIST_PATH); - request.AddParameter("token", slackKey); - request.AddParameter("presence", "1"); - - var response = await _requestExecutor.Execute(request); - return response.Members; - } - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Channel/FlurlChannelClient.cs b/src/SlackConnector/Connections/Clients/Channel/FlurlChannelClient.cs new file mode 100644 index 0000000..9150979 --- /dev/null +++ b/src/SlackConnector/Connections/Clients/Channel/FlurlChannelClient.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using Flurl; +using Flurl.Http; +using SlackConnector.Connections.Models; +using SlackConnector.Connections.Responses; + +namespace SlackConnector.Connections.Clients.Channel +{ + internal class FlurlChannelClient : IChannelClient + { + private readonly IResponseVerifier _responseVerifier; + internal const string JOIN_DM_PATH = "/api/im.open"; + internal const string CHANNELS_LIST_PATH = "/api/channels.list"; + internal const string GROUPS_LIST_PATH = "/api/groups.list"; + internal const string USERS_LIST_PATH = "/api/users.list"; + + public FlurlChannelClient(IResponseVerifier responseVerifier) + { + _responseVerifier = responseVerifier; + } + + public async Task JoinDirectMessageChannel(string slackKey, string user) + { + var response = await ClientConstants + .SlackApiHost + .AppendPathSegment(JOIN_DM_PATH) + .SetQueryParam("token", slackKey) + .SetQueryParam("user", user) + .GetJsonAsync(); + + _responseVerifier.VerifyResponse(response); + return response.Channel; + } + + public async Task GetChannels(string slackKey) + { + var response = await ClientConstants + .SlackApiHost + .AppendPathSegment(CHANNELS_LIST_PATH) + .SetQueryParam("token", slackKey) + .GetJsonAsync(); + + _responseVerifier.VerifyResponse(response); + return response.Channels; + } + + public async Task GetGroups(string slackKey) + { + var response = await ClientConstants + .SlackApiHost + .AppendPathSegment(GROUPS_LIST_PATH) + .SetQueryParam("token", slackKey) + .GetJsonAsync(); + + _responseVerifier.VerifyResponse(response); + return response.Groups; + } + + public async Task GetUsers(string slackKey) + { + var response = await ClientConstants + .SlackApiHost + .AppendPathSegment(USERS_LIST_PATH) + .SetQueryParam("token", slackKey) + .SetQueryParam("presence", "1") + .GetJsonAsync(); + + _responseVerifier.VerifyResponse(response); + return response.Members; + } + } +} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Chat/ChatClient.cs b/src/SlackConnector/Connections/Clients/Chat/ChatClient.cs deleted file mode 100644 index 03c146e..0000000 --- a/src/SlackConnector/Connections/Clients/Chat/ChatClient.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json; -using RestSharp; -using SlackConnector.Connections.Responses; -using SlackConnector.Models; - -namespace SlackConnector.Connections.Clients.Chat -{ - internal class ChatClient : IChatClient - { - private readonly IRequestExecutor _requestExecutor; - internal const string SEND_MESSAGE_PATH = "/api/chat.postMessage"; - - public ChatClient(IRequestExecutor requestExecutor) - { - _requestExecutor = requestExecutor; - } - - public async Task PostMessage(string slackKey, string channel, string text, IList attachments) - { - var request = new RestRequest(SEND_MESSAGE_PATH); - request.AddParameter("token", slackKey); - request.AddParameter("channel", channel); - request.AddParameter("text", text); - request.AddParameter("as_user", "true"); - - if (attachments != null && attachments.Any()) - { - request.AddParameter("attachments", JsonConvert.SerializeObject(attachments)); - } - - await _requestExecutor.Execute(request); - } - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Chat/FlurlChatClient.cs b/src/SlackConnector/Connections/Clients/Chat/FlurlChatClient.cs new file mode 100644 index 0000000..7bc1106 --- /dev/null +++ b/src/SlackConnector/Connections/Clients/Chat/FlurlChatClient.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Flurl; +using Flurl.Http; +using Newtonsoft.Json; +using SlackConnector.Connections.Responses; +using SlackConnector.Models; + +namespace SlackConnector.Connections.Clients.Chat +{ + internal class FlurlChatClient : IChatClient + { + private readonly IResponseVerifier _responseVerifier; + internal const string SEND_MESSAGE_PATH = "/api/chat.postMessage"; + + public FlurlChatClient(IResponseVerifier responseVerifier) + { + _responseVerifier = responseVerifier; + } + + public async Task PostMessage(string slackKey, string channel, string text, IList attachments) + { + var request = ClientConstants + .SlackApiHost + .AppendPathSegment(SEND_MESSAGE_PATH) + .SetQueryParam("token", slackKey) + .SetQueryParam("channel", channel) + .SetQueryParam("text", text) + .SetQueryParam("as_user", "true"); + + if (attachments != null && attachments.Any()) + { + request.SetQueryParam("attachments", JsonConvert.SerializeObject(attachments)); + } + + var response = await request.GetJsonAsync(); + _responseVerifier.VerifyResponse(response); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/ClientConstants.cs b/src/SlackConnector/Connections/Clients/ClientConstants.cs new file mode 100644 index 0000000..07b5c14 --- /dev/null +++ b/src/SlackConnector/Connections/Clients/ClientConstants.cs @@ -0,0 +1,7 @@ +namespace SlackConnector.Connections.Clients +{ + internal static class ClientConstants + { + internal const string SlackApiHost = "https://slack.com"; + } +} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/File/FileClient.cs b/src/SlackConnector/Connections/Clients/File/FileClient.cs deleted file mode 100644 index 1484b66..0000000 --- a/src/SlackConnector/Connections/Clients/File/FileClient.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.IO; -using System.Threading.Tasks; -using RestSharp; -using SlackConnector.Connections.Responses; - -namespace SlackConnector.Connections.Clients.File -{ - internal class FileClient : IFileClient - { - private readonly IRequestExecutor _requestExecutor; - internal const string FILE_UPLOAD_PATH = "/api/files.upload"; - - public FileClient(IRequestExecutor requestExecutor) - { - _requestExecutor = requestExecutor; - } - - public async Task PostFile(string slackKey, string channel, string file) - { - var request = new RestRequest(FILE_UPLOAD_PATH); - request.AddParameter("token", slackKey); - request.AddParameter("channels", channel); - request.AddParameter("filename", Path.GetFileName(file)); - request.AddFile("file", file); - - await _requestExecutor.Execute(request); - } - - public async Task PostFile(string slackKey, string channel, Stream stream, string fileName) - { - var request = new RestRequest(FILE_UPLOAD_PATH); - request.AddParameter("token", slackKey); - request.AddParameter("channels", channel); - request.AddParameter("filename", fileName); - - byte[] data = await ReadByteArray(stream); - request.AddFile("file", data, fileName); - - await _requestExecutor.Execute(request); - } - - private async Task ReadByteArray(Stream stream) - { - var memoryStream = stream as MemoryStream; - if (memoryStream != null) - { - return memoryStream.ToArray(); - } - - using (memoryStream = new MemoryStream()) - { - await stream.CopyToAsync(memoryStream); - return memoryStream.ToArray(); - } - } - } -} diff --git a/src/SlackConnector/Connections/Clients/File/FlurlFileClient.cs b/src/SlackConnector/Connections/Clients/File/FlurlFileClient.cs new file mode 100644 index 0000000..7b14328 --- /dev/null +++ b/src/SlackConnector/Connections/Clients/File/FlurlFileClient.cs @@ -0,0 +1,49 @@ +using System.IO; +using System.Threading.Tasks; +using Flurl; +using Flurl.Http; +using Newtonsoft.Json; +using SlackConnector.Connections.Responses; + +namespace SlackConnector.Connections.Clients.File +{ + internal class FlurlFileClient : IFileClient + { + private readonly IResponseVerifier _responseVerifier; + internal const string FILE_UPLOAD_PATH = "/api/files.upload"; + internal const string POST_FILE_VARIABLE_NAME = "file"; + + public FlurlFileClient(IResponseVerifier responseVerifier) + { + _responseVerifier = responseVerifier; + } + + public async Task PostFile(string slackKey, string channel, string filePath) + { + var httpResponse = await ClientConstants + .SlackApiHost + .AppendPathSegment(FILE_UPLOAD_PATH) + .SetQueryParam("token", slackKey) + .SetQueryParam("channels", channel) + .PostMultipartAsync(content => content.AddFile(POST_FILE_VARIABLE_NAME, filePath)); + + var responseContent = await httpResponse.Content.ReadAsStringAsync(); + var response = JsonConvert.DeserializeObject(responseContent); + _responseVerifier.VerifyResponse(response); + } + + public async Task PostFile(string slackKey, string channel, Stream stream, string fileName) + { + var httpResponse = await ClientConstants + .SlackApiHost + .AppendPathSegment(FILE_UPLOAD_PATH) + .SetQueryParam("token", slackKey) + .SetQueryParam("channels", channel) + .PostMultipartAsync(content => content.AddFile(POST_FILE_VARIABLE_NAME, stream, fileName)); + + var responseContent = await httpResponse.Content.ReadAsStringAsync(); + var response = JsonConvert.DeserializeObject(responseContent); + _responseVerifier.VerifyResponse(response); + } + } +} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Handshake/FlurlHandshakeClient.cs b/src/SlackConnector/Connections/Clients/Handshake/FlurlHandshakeClient.cs new file mode 100644 index 0000000..9c0101a --- /dev/null +++ b/src/SlackConnector/Connections/Clients/Handshake/FlurlHandshakeClient.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; +using Flurl; +using Flurl.Http; +using SlackConnector.Connections.Responses; + +namespace SlackConnector.Connections.Clients.Handshake +{ + internal class FlurlHandshakeClient : IHandshakeClient + { + private readonly IResponseVerifier _responseVerifier; + internal const string HANDSHAKE_PATH = "/api/rtm.start"; + + public FlurlHandshakeClient(IResponseVerifier responseVerifier) + { + _responseVerifier = responseVerifier; + } + + public async Task FirmShake(string slackKey) + { + var response = await ClientConstants + .SlackApiHost + .AppendPathSegment(HANDSHAKE_PATH) + .SetQueryParam("token", slackKey) + .GetJsonAsync(); + + _responseVerifier.VerifyResponse(response); + return response; + } + } +} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/Handshake/HandshakeClient.cs b/src/SlackConnector/Connections/Clients/Handshake/HandshakeClient.cs deleted file mode 100644 index a7e767f..0000000 --- a/src/SlackConnector/Connections/Clients/Handshake/HandshakeClient.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; -using RestSharp; -using SlackConnector.Connections.Responses; - -namespace SlackConnector.Connections.Clients.Handshake -{ - internal class HandshakeClient : IHandshakeClient - { - private readonly IRequestExecutor _requestExecutor; - internal const string HANDSHAKE_PATH = "/api/rtm.start"; - - public HandshakeClient(IRequestExecutor requestExecutor) - { - _requestExecutor = requestExecutor; - } - - public async Task FirmShake(string slackKey) - { - var request = new RestRequest(HANDSHAKE_PATH); - request.AddParameter("token", slackKey); - - return await _requestExecutor.Execute(request); - } - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/IRequestExecutor.cs b/src/SlackConnector/Connections/Clients/IRequestExecutor.cs deleted file mode 100644 index ec8e2eb..0000000 --- a/src/SlackConnector/Connections/Clients/IRequestExecutor.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Threading.Tasks; -using RestSharp; - -namespace SlackConnector.Connections.Clients -{ - internal interface IRequestExecutor - { - Task Execute(IRestRequest request) where T : class; - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/IResponseVerifier.cs b/src/SlackConnector/Connections/Clients/IResponseVerifier.cs index 175cfb5..04db6c7 100644 --- a/src/SlackConnector/Connections/Clients/IResponseVerifier.cs +++ b/src/SlackConnector/Connections/Clients/IResponseVerifier.cs @@ -1,9 +1,9 @@ -using RestSharp; +using SlackConnector.Connections.Responses; namespace SlackConnector.Connections.Clients { internal interface IResponseVerifier { - T VerifyResponse(IRestResponse response) where T : class; + void VerifyResponse(StandardResponse response); } } \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/RequestExecutor.cs b/src/SlackConnector/Connections/Clients/RequestExecutor.cs deleted file mode 100644 index f5c96f1..0000000 --- a/src/SlackConnector/Connections/Clients/RequestExecutor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Threading.Tasks; -using RestSharp; - -namespace SlackConnector.Connections.Clients -{ - internal class RequestExecutor : IRequestExecutor - { - internal const string SLACK_URL = "https://slack.com"; - - private readonly IRestSharpFactory _restSharpFactory; - private readonly IResponseVerifier _responseVerifier; - - public RequestExecutor(IRestSharpFactory restSharpFactory, IResponseVerifier responseVerifier) - { - _restSharpFactory = restSharpFactory; - _responseVerifier = responseVerifier; - } - - public async Task Execute(IRestRequest request) where T : class - { - IRestClient client = _restSharpFactory.CreateClient(SLACK_URL); - IRestResponse response = await client.ExecutePostTaskAsync(request); - return _responseVerifier.VerifyResponse(response); - } - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/Clients/ResponseVerifier.cs b/src/SlackConnector/Connections/Clients/ResponseVerifier.cs index 8417c26..9356319 100644 --- a/src/SlackConnector/Connections/Clients/ResponseVerifier.cs +++ b/src/SlackConnector/Connections/Clients/ResponseVerifier.cs @@ -1,6 +1,5 @@ using System.Net; using Newtonsoft.Json; -using RestSharp; using SlackConnector.Connections.Responses; using SlackConnector.Exceptions; @@ -8,20 +7,12 @@ namespace SlackConnector.Connections.Clients { internal class ResponseVerifier : IResponseVerifier { - public T VerifyResponse(IRestResponse response) where T : class + public void VerifyResponse(StandardResponse response) { - if (response.StatusCode != HttpStatusCode.OK) + if (!response.Ok) { - throw new CommunicationException($"Error occured while sending message '{response.StatusCode}'"); + throw new CommunicationException($"Error occured while posting message '{response.Error}'"); } - - var result = JsonConvert.DeserializeObject(response.Content, typeof (T)) as StandardResponse; - if (!result.Ok) - { - throw new CommunicationException($"Error occured while posting message '{result.Error}'"); - } - - return result as T; } } } \ No newline at end of file diff --git a/src/SlackConnector/Connections/ConnectionFactory.cs b/src/SlackConnector/Connections/ConnectionFactory.cs index c8704fe..6e1e1a4 100644 --- a/src/SlackConnector/Connections/ConnectionFactory.cs +++ b/src/SlackConnector/Connections/ConnectionFactory.cs @@ -11,15 +11,6 @@ namespace SlackConnector.Connections { internal class ConnectionFactory : IConnectionFactory { - private readonly IRequestExecutor _requestExecutor; - - public ConnectionFactory() - { - IRestSharpFactory restSharpFactory = new RestSharpFactory(); - IResponseVerifier responseVerifier = new ResponseVerifier(); - _requestExecutor = new RequestExecutor(restSharpFactory, responseVerifier); - } - public IWebSocketClient CreateWebSocketClient(string url, ProxySettings proxySettings) { return new WebSocketClient(new MessageInterpreter(new Logger()), url, proxySettings); @@ -27,22 +18,22 @@ public IWebSocketClient CreateWebSocketClient(string url, ProxySettings proxySet public IHandshakeClient CreateHandshakeClient() { - return new HandshakeClient(_requestExecutor); + return new FlurlHandshakeClient(new ResponseVerifier()); } public IChatClient CreateChatClient() { - return new ChatClient(_requestExecutor); + return new FlurlChatClient(new ResponseVerifier()); } public IFileClient CreateFileClient() { - return new FileClient(_requestExecutor); + return new FlurlFileClient(new ResponseVerifier()); } public IChannelClient CreateChannelClient() { - return new ChannelClient(_requestExecutor); + return new FlurlChannelClient(new ResponseVerifier()); } } } \ No newline at end of file diff --git a/src/SlackConnector/Connections/IRestSharpFactory.cs b/src/SlackConnector/Connections/IRestSharpFactory.cs deleted file mode 100644 index c43eef3..0000000 --- a/src/SlackConnector/Connections/IRestSharpFactory.cs +++ /dev/null @@ -1,9 +0,0 @@ -using RestSharp; - -namespace SlackConnector.Connections -{ - internal interface IRestSharpFactory - { - IRestClient CreateClient(string baseUrl); - } -} \ No newline at end of file diff --git a/src/SlackConnector/Connections/RestSharpFactory.cs b/src/SlackConnector/Connections/RestSharpFactory.cs deleted file mode 100644 index 1968d8b..0000000 --- a/src/SlackConnector/Connections/RestSharpFactory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using RestSharp; - -namespace SlackConnector.Connections -{ - internal class RestSharpFactory : IRestSharpFactory - { - public IRestClient CreateClient(string baseUrl) - { - return new RestClient(baseUrl); - } - } -} \ No newline at end of file diff --git a/src/SlackConnector/Properties/AssemblyInfo.cs b/src/SlackConnector/Properties/AssemblyInfo.cs index 9572157..0cac20e 100644 --- a/src/SlackConnector/Properties/AssemblyInfo.cs +++ b/src/SlackConnector/Properties/AssemblyInfo.cs @@ -36,4 +36,5 @@ [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: InternalsVisibleTo("SlackConnector.Tests.Unit")] +[assembly: InternalsVisibleTo("SlackConnector.Tests.Integration")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/SlackConnector/SlackConnector.csproj b/src/SlackConnector/SlackConnector.csproj index cf23445..52a86b0 100644 --- a/src/SlackConnector/SlackConnector.csproj +++ b/src/SlackConnector/SlackConnector.csproj @@ -9,7 +9,7 @@ Properties SlackConnector SlackConnector - v4.6 + v4.6.1 512 @@ -32,22 +32,69 @@ 4 - - ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + + ..\..\packages\Flurl.2.2.1\lib\netstandard1.4\Flurl.dll True - - ..\..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll + + ..\..\packages\Flurl.Http.1.1.1\lib\net45\Flurl.Http.dll + True + + + ..\..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll + True + + + ..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True + + ..\..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + True + + + ..\..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll + True + + + ..\..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + ..\..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll + True + + + ..\..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net46\System.Reflection.TypeExtensions.dll + True + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll + True + + + ..\..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + + + ..\..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + + + ..\..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll + True + - ..\..\packages\websocket-sharp-with-proxy-support.1.9.1\lib\net35-client\websocket-sharp-with-proxy-support.dll @@ -59,17 +106,16 @@ - + + + + - - + - - - @@ -79,10 +125,8 @@ - - diff --git a/src/SlackConnector/app.config b/src/SlackConnector/app.config index 1eb16eb..72c1eb0 100644 --- a/src/SlackConnector/app.config +++ b/src/SlackConnector/app.config @@ -1,11 +1,23 @@ - + - - + + + + + + + + + + + + + + - + diff --git a/src/SlackConnector/packages.config b/src/SlackConnector/packages.config index 9f721e7..f212dae 100644 --- a/src/SlackConnector/packages.config +++ b/src/SlackConnector/packages.config @@ -1,6 +1,20 @@  - - - + + + + + + + + + + + + + + + + + \ No newline at end of file