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 TestGetModuleFolderWithMultipleNamesInPath()
 {
     IRoot root = new Root(_repoPath, _module, _hostName, _port, _user, _pwd);
      DirectoryInfo di = new DirectoryInfo(@"c:\_temp");
      root.WorkingDirectory = di;
      root.Module = "rootmod/mymod";
      Folder modFolder = root.RootFolder;
      Assert.AreEqual(@"c:\_temp\rootmod\mymod", modFolder.Info.FullName, "path is not corrent");
 }
        public void ConnectTest()
        {
            Expect.Call(() => _client.Connect(null, 0))
            .IgnoreArguments()
            .Constraints(Is.Equal("host-name"), Is.Equal(2401));
             _mocks.ReplayAll();

             IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
             _connection.Connect(root);
             _mocks.VerifyAll();
        }
 public void TestRootConstructor()
 {
     IRoot root = new Root(_repoPath, _module, _hostName, _port, _user, _pwd);
      string expected = ":pserver:username@host-name:2401/f1/f2/f3";
      Assert.AreEqual(expected, root.CVSConnectionString);
      Assert.AreEqual(_hostName, root.Host);
      Assert.AreEqual(_user, root.Username);
      Assert.AreNotEqual(_pwd, root.Password);
      Assert.AreEqual(_pwd.ScramblePassword(), root.Password);
      Assert.AreEqual(_repoPath, root.Repository);
      Assert.AreEqual(2401, root.Port);
 }
 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 TestCommandToXML()
        {
            IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
             root.WorkingDirectory = TestConfig.WorkingDirectory;
             MockRepository mocks = new MockRepository();
             IConnection connection = mocks.Stub<IConnection>();
             CheckOutCommand cmd = new CheckOutCommand(root, connection);

             // add requests to items
             foreach (ICommandItem item in cmd.RequiredRequests)
             {
            cmd.Items.Add(item);
             }

             foreach (ICommandItem item in cmd.Requests)
             {
            cmd.Items.Add(item);
             }

             // add responses to command
             IResponse response = new AuthResponse();
             IList<string> process = new List<string> { "I LOVE YOU" };
             response.Initialize(process);
             cmd.Items.Add(response);

             response = new ValidRequestsResponse();
             IList<string> lines = new List<string> { "Root Valid-responses valid-requests Global_option" };
             response.Initialize(lines);
             cmd.Items.Add(response);

             IList<IResponse> coresponses = TestHelper.GetMockCheckoutResponses("8 Dec 2009 15:26:27 -0000", "mymod/", "file1.cs");
             foreach (IResponse cor in coresponses)
             {
            cmd.Responses.Add(cor);
             }

             XDocument xdoc = cmd.GetXDocument();
             Console.WriteLine(xdoc.ToString());
             bool result = TestHelper.ValidateCommandXML(xdoc);
             Assert.IsTrue(result);
        }
        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 SetUp()
        {
            string hostName = "host-name";
             int port = 1;
             string user = "******";
             string pwd = "password";
             string repoPath = "/f1/f2/f3";

             _root = new Root(hostName, port, user, pwd, repoPath);

             _working = new DirectoryInfo(@"c:\_temp");
             _root.WorkingDirectory = _working;
             _root.Module = _module;
             _fileReceiver = new CVSFileReceiver(_root);

             if (_working.Exists)
            _working.Delete(true);
             _working.Refresh();
        }
 public void TestRoot()
 {
     IRoot root = new Root(TestConfig.RepositoryPath, TestConfig.ModuleName, TestConfig.CVSHost, TestConfig.CVSPort, TestConfig.Username, TestConfig.Password);
      root.WorkingDirectory = TestConfig.WorkingDirectory;
      root.Repository = _repository;
      Assert.AreEqual(_connection, root.CVSConnectionString);
 }