public void Post_PassNotExistingUrls_ThrowsHandledException()
        {
            // Arrange
            var url = new Uri("http://0.0.0.0:80/");

            // Act
            using (var request = new VocabularyRequest(url, "add"))
            {
                // Assert
                var ex = Assert.Throws <AggregateException>(() => request.PostAsync().Wait());
                Assert.IsInstanceOf <ApplicationException>(ex.InnerException);
                Assert.IsInstanceOf <HttpRequestException>(ex.InnerException.InnerException);
            }
        }
        public async Task ProcessRequest_HandlerThorwsException_ReceiveInternalServerError()
        {
            // Arrange
            using (var server = new VocabularyServer(VocabularyRequestHandlerStabFactory.ExceptionHandle(), Url))
            {
                var start = server.StartAsync();
                using (var request = new VocabularyRequest(new Uri(Url), "add"))
                {
                    // Act
                    var responce = await request.PostAsync();

                    // Assert
                    Assert.AreEqual(responce, string.Format(Resources.Default.ResponseErrorCode, "InternalServerError"));
                }

                server.Stop();
            }
        }
        /// <summary>
        /// Выполняет команды к серверу, возвращает последний ответ сервера
        /// </summary>
        /// <param name="commands">Команды</param>
        /// <returns></returns>
        private async Task <string> ExecuteCommandsAsync(string[] commands)
        {
            // Arrange
            string response = string.Empty;

            using (var server = new VocabularyServerFactory().Get(Url))
            {
                await Task.Factory.StartNew(async() => await server.StartAsync()).ConfigureAwait(false);

                foreach (var command in commands)
                {
                    using (var request = new VocabularyRequest(new Uri(Url), command))
                    {
                        // Act
                        response = await request.PostAsync();
                    }
                }
                server.Stop();
            }

            return(response);
        }
        public async Task ProcessRequest_HandlerReturnResult_ReceiveThatResult()
        {
            // Arrange
            var command = "aaa";
            var result  = "bbb";

            using (var server = new VocabularyServer(
                       VocabularyRequestHandlerStabFactory.Handle(command, result), Url))
            {
                var start = server.StartAsync();
                using (var request = new VocabularyRequest(new Uri(Url), command))
                {
                    // Act
                    var responce = await request.PostAsync();

                    // Assert
                    Assert.AreEqual(responce, result);
                }

                server.Stop();
            }
        }