public void EnsureCreateStream_uses_retry_strategy()
        {
            var uidList = new UserIdList();

            _streamsApi.CreateStream(uidList);
            _apiExecutorMock.Verify(obj => obj.Execute(It.IsAny <Func <UserIdList, string, Stream> >(), uidList, "sessionToken"));
        }
        public void EnsureCreateStream_uses_retry_strategy()
        {
            var uidList = new List <long>();

            _apiExecutorMock.Setup(
                apiExecutor =>
                apiExecutor.Execute(It.IsAny <Func <UserIdList, string, Generated.OpenApi.PodApi.Model.Stream> >(), It.IsAny <UserIdList>(),
                                    "sessionToken")).Returns(new Generated.OpenApi.PodApi.Model.Stream("sid"));
            _streamsApi.CreateStream(uidList);
            _apiExecutorMock.Verify(obj => obj.Execute(It.IsAny <Func <UserIdList, string, Generated.OpenApi.PodApi.Model.Stream> >(), It.IsAny <UserIdList>(), "sessionToken"));
        }
        public void EnsureCreateStream_uses_retry_strategy()
        {
            var uidList = new List <long>();

            _apiExecutorMock.Setup(
                apiExecutor =>
                apiExecutor.Execute(It.IsAny <Func <List <long>, string, CancellationToken, Task <Generated.OpenApi.PodApi.Stream> > >(), It.IsAny <List <long> >(),
                                    "sessionToken", default(CancellationToken))).Returns(new Generated.OpenApi.PodApi.Stream()
            {
                Id = "sid"
            });
            _streamsApi.CreateStream(uidList);
            _apiExecutorMock.Verify(obj => obj.Execute(It.IsAny <Func <List <long>, string, CancellationToken, Task <Generated.OpenApi.PodApi.Stream> > >(), It.IsAny <List <long> >(), "sessionToken", default(CancellationToken)));
        }
        private void SendMessage(User user, string messageText)
        {
            string streamId;

            try
            {
                streamId = streamsApi_.CreateStream(new List <long> {
                    user.Id
                });
            }
            catch (Exception e)
            {
                Logger.Error(string.Format("Failed to create chat with {0}: {1}",
                                           user.EmailAddress,
                                           e),
                             e);
                throw new Exception("Failed to create chat with " + user.EmailAddress, e);
            }

            Logger.InfoFormat("Sending {0} to {1}", messageText, user.EmailAddress);

            try
            {
                var message = new Message(streamId, MessageFormat.Text, messageText);
                messagesApi_.PostMessage(message);
            }
            catch (Exception e)
            {
                Logger.Error(string.Format("Failed to send {0} to {1}: {2}",
                                           messageText,
                                           user.EmailAddress,
                                           e),
                             e);
                throw new Exception("Failed to send " + messageText + " to " + user.EmailAddress, e);
            }
        }