private async Task should_upload_file_from_stream( [Frozen] Mock <IConnectionFactory> connectionFactory, Mock <IFileClient> fileClient, Mock <IWebSocketClient> webSocket, SlackConnection slackConnection) { // given const string slackKey = "key-yay"; const string fileName = "expected-file-name"; var chatHub = new SlackChatHub { Id = "channelz-id" }; var stream = new MemoryStream(); var connectionInfo = new ConnectionInformation { WebSocket = webSocket.Object, SlackKey = slackKey }; await slackConnection.Initialise(connectionInfo); connectionFactory .Setup(x => x.CreateFileClient()) .Returns(fileClient.Object); // when await slackConnection.Upload(chatHub, stream, fileName); // then fileClient .Verify(x => x.PostFile(slackKey, chatHub.Id, stream, fileName), Times.Once); }
public async Task should_upload_to_channel_from_file_system() { // given var chatHub = SlackConnection.ConnectedChannel(Config.Slack.TestChannel); // when await SlackConnection.Upload(chatHub, _filePath); // then }
public async Task should_upload_to_channel_from_stream() { // given var chatHub = SlackConnection.ConnectedChannel(Config.Slack.TestChannel); const string fileName = "slackconnector-test-stream-upload.txt"; // when using (var fileStream = EmbeddedResourceFileReader.ReadEmbeddedFile("UploadTest.txt")) { await SlackConnection.Upload(chatHub, fileStream, fileName); } // then }