public void S2_PublishApplication_AlreadyPublished_Fail()
        {
            // trigger the client to publish an application asynchronously
            // so that it does not block the main thread
            var sut = AsyncSutAdapter.TriggerPublishApplicationAsync();

            TestSite.Log.Add(LogEntryKind.Comment, "Triggering proxy client to publish a web application");

            // start receiving client request
            // when request comes, forward it to the corresponding handler
            while ((CurrentRequest = ClientAdapter.ExpectRequest()) != null)
            {
                TestSite.Log.Add(LogEntryKind.Comment, "Received request for " + CurrentRequest.RequestUri.AbsolutePath);

                CurrentHandler = (ProxyRequestHandlerBase)Factory.GetRequestHandler(CurrentRequest);
                TestSite.Assert.IsTrue(CurrentHandler.VerifyRequest(out VerifyMessage), VerifyMessage);

                if (CurrentHandler is PostProxyPublishSettingsRequestHandler)
                {
                    CurrentResponse = ((PostProxyPublishSettingsRequestHandler)CurrentHandler)
                                      .GetConflictResponse();
                }
                else
                {
                    CurrentResponse = CurrentHandler.GetResponse();
                }

                ClientAdapter.SendResponse(CurrentResponse);
                TestSite.Log.Add(LogEntryKind.Comment, "Response has been sent to the client.");
            }

            TestSite.Assert.IsFalse(sut.Result.Return, "The client acted correctly with 409 response.");
        }
        public void S2_PublishApplication_Success()
        {
            // trigger the client to publish an application asynchronously
            // so that it does not block the main thread
            var sut = AsyncSutAdapter.TriggerPublishApplicationAsync();

            TestSite.Log.Add(LogEntryKind.Comment, "Triggering proxy client to publish a web application");

            // start receiving client request
            // when request comes, forward it to the corresponding handler
            while ((CurrentRequest = ClientAdapter.ExpectRequest()) != null)
            {
                TestSite.Log.Add(LogEntryKind.Comment, "Received request for " + CurrentRequest.RequestUri.AbsolutePath);

                CurrentHandler = (ProxyRequestHandlerBase)Factory.GetRequestHandler(CurrentRequest);
                TestSite.Assert.IsTrue(CurrentHandler.VerifyRequest(out VerifyMessage), VerifyMessage);

                CurrentResponse = CurrentHandler.GetResponse();
                ClientAdapter.SendResponse(CurrentResponse);
                TestSite.Log.Add(LogEntryKind.Comment, "Response has been sent to the client.");
            }

            // check whether the client has published the application successfully
            TestSite.Assert.IsTrue(sut.Result.Return,
                                   string.IsNullOrEmpty(sut.Result.Error)
                ? "The client has published the application successfully. "
                : sut.Result.Error);
        }