public void TestCollapseMessageResponses()
      {
         DirectoryInfo di = Directory.GetParent(Environment.CurrentDirectory);

         FileInfo fi = new FileInfo(Path.Combine(di.FullName, "TestSetup\\ExportCommandWithEMessages.xml"));
         TextReader reader = fi.OpenText();
         XDocument xdoc = XDocument.Load(reader);
         ////bool result = TestHelper.ValidateCommandXML(xdoc);
         ////Assert.IsTrue(result);
         IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
         root.WorkingDirectory = TestConfig.WorkingDirectory;
         PServerFactory factory = new PServerFactory();
         IConnection connection = new PServerConnection();
         ICommand cmd = factory.CreateCommand(xdoc, new object[] { root, connection });
         int count = cmd.Items.OfType<IResponse>().Count();
         Assert.AreEqual(18, count);
         count = cmd.Items.OfType<EMessageResponse>().Count();
         Assert.AreEqual(12, count);
         IList<IResponse> responses = cmd.Items.OfType<IResponse>().ToList();
         IList<IResponse> condensed = ResponseHelper.CollapseMessagesInResponses(responses);
         Assert.AreEqual(7, condensed.Count);
         IMessageResponse message = (IMessageResponse)condensed[5];
         Assert.AreEqual(12, message.Lines.Count);
         Console.WriteLine(message.Display());
      }
 public void TestProcessFiles()
 {
     DirectoryInfo di = Directory.GetParent(Environment.CurrentDirectory);
      FileInfo fi = new FileInfo(Path.Combine(di.FullName, "TestSetup\\ExportCommand.xml"));
      TextReader reader = fi.OpenText();
      XDocument xdoc = XDocument.Load(reader);
      bool result = TestHelper.ValidateCommandXML(xdoc);
      Assert.IsTrue(result);
      PServerFactory factory = new PServerFactory();
      IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
      root.WorkingDirectory = TestConfig.WorkingDirectory;
      DateTime date = new DateTime();
      ExportCommand cmd = (ExportCommand)factory.CreateCommand(xdoc, new object[] { root, date });
      cmd.AfterExecute();
      ////Assert.AreEqual(4, cmd.FileGroups.Count);
 }
        public void TestCommandXMLToCommandObject()
        {
            string xml = TestStrings.CommandXMLFileWithManyItems;
             XDocument xdoc = XDocument.Parse(xml);
             bool result = TestHelper.ValidateCommandXML(xdoc);
             Assert.IsTrue(result);
             IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
             root.WorkingDirectory = TestConfig.WorkingDirectory;
             PServerFactory factory = new PServerFactory();
             IConnection connection = new PServerConnection();
             ICommand cmd = factory.CreateCommand(xdoc, new object[] { root, connection });
             Assert.IsInstanceOf<CheckOutCommand>(cmd);

             Assert.AreEqual(2, cmd.RequiredRequests.Count);
             Assert.AreEqual(3, cmd.Requests.Count);
             Assert.AreEqual(3, cmd.Items.OfType<IResponse>().Count());
        }
 public void TestImportXMLResponseWithMultipleLines()
 {
     string xml = TestStrings.MTResponse;
      XElement responseElement = XElement.Parse(xml);
      PServerFactory factory = new PServerFactory();
      IResponse response = factory.ResponseXElementToIResponse(responseElement);
      Assert.AreEqual(5, response.Lines.Count);
 }
 public void TestGetResponseFromXML()
 {
     string xml = TestStrings.AuthResponseXML;
      XElement responseElement = XElement.Parse(xml);
      bool result = TestHelper.ValidateResponseXML(responseElement);
      Assert.IsTrue(result);
      PServerFactory factory = new PServerFactory();
      IResponse response = factory.ResponseXElementToIResponse(responseElement);
      Assert.IsNotNull(response);
      Assert.IsInstanceOf<AuthResponse>(response);
      Assert.AreEqual("I LOVE YOU", response.Display());
 }
 public void TestFileResponseFromXML()
 {
     string xml = TestStrings.UpdatedResponseXML;
      XElement responseElement = XElement.Parse(xml);
      bool result = TestHelper.ValidateResponseXML(responseElement);
      Assert.IsTrue(result);
      PServerFactory factory = new PServerFactory();
      IResponse response = factory.ResponseXElementToIResponse(responseElement);
      Assert.IsNotNull(response);
      Assert.IsInstanceOf<UpdatedResponse>(response);
      IFileResponse fileResponse = (IFileResponse)response;
      Assert.AreEqual(74, fileResponse.Length);
      string expected = "/1 :pserver:abougie@gb-aix-q:2401/usr/local/cvsroot/sandbox AB4%o=wSobI4w\n";
      string fileContents = fileResponse.Contents.Decode();
      Assert.AreEqual(expected, fileContents);
 }
        /// <summary>
        /// Gets one response.
        /// </summary>
        /// <returns>the response instance</returns>
        public IResponse GetResponse()
        {
            IResponse response = null;
             string line = _cvsTcpClient.ReadLine();  // ReadLine();
             Console.WriteLine("S: " + (line ?? string.Empty));

             if (line != null)
             {
            PServerFactory factory = new PServerFactory();
            ResponseType responseType = factory.GetResponseType(line);
            response = factory.CreateResponse(responseType);
            IList<string> responseLines = GetResponseLines(line, responseType, response.LineCount);
            response.Initialize(responseLines);
            ////if (response is IFileResponse)
            ////{
            ////   response.Process();
            ////   IFileResponse fileResponse = (IFileResponse) response;
            ////   fileResponse.Contents = TcpClient.ReadBytes((int) fileResponse.Length);
            ////}
             }

             return response;
        }