BitKeeperHistoryParserTest.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » UnitTests » Core » Sourcecontrol » Bitkeeper » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » UnitTests » Core » Sourcecontrol » Bitkeeper » BitKeeperHistoryParserTest.cs
using System;
using System.IO;
using NUnit.Framework;
using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Core.Sourcecontrol.BitKeeper;

namespace ThoughtWorks.CruiseControl.UnitTests.Core.Sourcecontrol.Bitkeeper{
  [TestFixture]
  public class BitKeeperHistoryParserTest
  {
    [Test]
    public void ParseChangeSets()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.ChangeSetsBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(2, mods.Length);

      // Check specifics of the ChangeSet mod
      Assert.AreEqual("user@host.(none)", mods[0].UserName);
      Assert.AreEqual("  Remove file in subdir.", mods[0].Comment);
      Assert.AreEqual("ChangeSet", mods[0].Type);
      Assert.AreEqual("ChangeSet", mods[0].FileName);
      Assert.AreEqual("", mods[0].FolderName);
    }

    [Test]
    public void ParseRenamed()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.RenamedBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(2, mods.Length);

      // Check specifics of the Renamed mod
      Assert.AreEqual("user@host.(none)", mods[1].UserName);
      Assert.AreEqual("    Rename: asubdir/baz.txt -> asubdir2/bazzz.txt", mods[1].Comment);
      Assert.AreEqual("Renamed", mods[1].Type);
      Assert.AreEqual("bazzz.txt", mods[1].FileName);
      Assert.AreEqual("asubdir2", mods[1].FolderName);
    }

    [Test]
    public void ParseDeletions()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.DeletionsBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(2, mods.Length);

      // Check specifics of the Deleted mod
      Assert.AreEqual("user@host.(none)", mods[1].UserName);
      Assert.AreEqual("    Delete: asubdir/baz.txt", mods[1].Comment);
      Assert.AreEqual("Deleted", mods[1].Type);
      Assert.AreEqual("baz.txt", mods[1].FileName);
      Assert.AreEqual("asubdir", mods[1].FolderName);
    }

    [Test]
    public void ParseAdditions()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.AdditionsBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(2, mods.Length);

      // Check specifics of the Added mod
      Assert.AreEqual("user@host.(none)", mods[1].UserName);
      Assert.AreEqual("    BitKeeper file /var/lib/bk/demo/dev-1.0/asubdir/baz.txt", mods[1].Comment);
      Assert.AreEqual("Added", mods[1].Type);
      Assert.AreEqual("baz.txt", mods[1].FileName);
      Assert.AreEqual("asubdir", mods[1].FolderName);
    }

    [Test]
    public void ParseVerboseModifications()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.VerboseBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(21, mods.Length);
      foreach (Modification mod in mods)
      {
        Assert.AreEqual("user@host.(none)", mod.UserName);
        Assert.IsNotNull("filename should not be null", mod.FileName);
      }
    }

        [Test]
        public void ParseVerbose40Modifications()
        {
            BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
            Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.VerboseBitKeeper40Output()), DateTime.Now, DateTime.Now);
            Assert.AreEqual(10, mods.Length);
            foreach (Modification mod in mods)
            {
                Assert.AreEqual("user@host.(none)", mod.UserName);
                Assert.IsNotNull("filename should not be null", mod.FileName);
            }
        }

    [Test]
    public void ParseNonVerboseModifications()
    {
      BitKeeperHistoryParser parser = new BitKeeperHistoryParser();
      Modification[] mods = parser.Parse(new StringReader(BitKeeperTestData.NonVerboseBitKeeperOutput()), DateTime.Now, DateTime.Now);
      Assert.AreEqual(7, mods.Length);
      foreach (Modification mod in mods)
      {
        Assert.AreEqual("user@host.(none)", mod.UserName);
        Assert.IsNotNull("filename should not be null", mod.FileName);
        Assert.AreEqual("ChangeSet", mod.Type);
      }
    }

    private class BitKeeperTestData
    {
      public static string ChangeSetsBitKeeperOutput()
      {
        return @"ChangeSet
  1.6 05/10/06 12:58:40 user@host.(none) +1 -0
  Remove file in subdir.

  BitKeeper/deleted/.del-baz.txt~7545e8a43744d49
    1.2 05/10/06 12:58:27 user@host.(none) +0 -0
    Delete: asubdir/baz.txt
";
      }

      public static string RenamedBitKeeperOutput()
      {
        return @"ChangeSet
  1.7 05/10/06 12:59:40 user@host.(none) +1 -0
  Rename file in subdir.

  asubdir2/bazzz.txt
    1.2 05/10/06 12:59:27 user@host.(none) +0 -0
    Rename: asubdir/baz.txt -> asubdir2/bazzz.txt
";
      }

      public static string DeletionsBitKeeperOutput()
      {
        return @"ChangeSet
  1.6 05/10/06 12:58:40 user@host.(none) +1 -0
  Remove file in subdir.

  BitKeeper/deleted/.del-baz.txt~7545e8a43744d49
    1.2 05/10/06 12:58:27 user@host.(none) +0 -0
    Delete: asubdir/baz.txt
";
      }

      public static string AdditionsBitKeeperOutput()
      {
        return @"ChangeSet
  1.5 05/10/06 12:58:11 user@host.(none) +1 -0
  Another new one.

  asubdir/baz.txt
    1.0 05/10/06 12:58:11 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/asubdir/baz.txt
";
      }

            public static string VerboseBitKeeper40Output()
            {
                return @"==== changes -R file://C:/foo/bar/dev-1.0 ====
ChangeSet@1.1409, 2006-07-14 22:58:22-07:00, user@host.(none) +1 -0
  Another test.

  test.txt@1.2, 2006-07-14 22:58:20-07:00, user@host.(none) +1 -0
    Another test.

ChangeSet@1.1403.1.1, 2006-07-14 22:52:33-07:00, user@host.(none) +1 -0
  testing post incoming trigger after upgrading to 4.0.

  test.txt@1.1, 2006-07-14 22:52:25-07:00, user@host.(none) +1 -0
    testing post incoming trigger after upgrading to 4.0.

  test.txt@1.0, 2006-07-14 22:52:25-07:00, user@host.(none) +0 -0

ChangeSet@1.1407, 2006-07-14 20:07:56-07:00, user@host.(none) +4 -0
  Added some more to the Update tool.  Fixed a bug in the hashing method.
  TAG: dev-8.0-2011

  CommonLib/Certificate.cpp@1.15, 2006-07-14 20:07:42-07:00, user@host.(none) +49 -12
    Fixed a bug in the hash method.

  CommonLib/Certificate.h@1.9, 2006-07-14 20:07:42-07:00, user@host.(none) +1 -1
    Fixed a bug in the hash method.

  UpdateTool/UpdateProc.cpp@1.3, 2006-07-14 20:07:42-07:00, user@host.(none) +49 -0
    Added methods to check for the correctness of the update file.

  UpdateTool/UpdateProc.h@1.2, 2006-07-14 20:07:42-07:00, user@host.(none) +4 -0
    Added methods to check for the correctness of the update file.

";
            }

      public static string VerboseBitKeeperOutput()
      {
        return @"ChangeSet
  1.7 05/10/06 12:59:40 user@host.(none) +1 -0
  Rename file in subdir.

  asubdir2/bazzz.txt
    1.2 05/10/06 12:59:27 user@host.(none) +0 -0
    Rename: asubdir/baz.txt -> asubdir2/bazzz.txt

ChangeSet
  1.6 05/10/06 12:58:40 user@host.(none) +1 -0
  Remove file in subdir.

  BitKeeper/deleted/.del-baz.txt~7545e8a43744d49
    1.2 05/10/06 12:58:27 user@host.(none) +0 -0
    Delete: asubdir/baz.txt

  asubdir/baz.txt
    1.1 05/10/06 12:58:11 user@host.(none) +1 -0
    Another new one.

ChangeSet
  1.5 05/10/06 12:58:11 user@host.(none) +1 -0
  Another new one.

  asubdir/baz.txt
    1.0 05/10/06 12:58:11 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/asubdir/baz.txt

ChangeSet
  1.4 05/10/06 12:55:38 user@host.(none) +1 -0
  Remove foo.txt.

  BitKeeper/deleted/.del-foo.txt~8259385fddc312ca
    1.2 05/10/06 12:55:24 user@host.(none) +0 -0
    Delete: foo.txt

  bar.txt
    1.1 05/10/06 12:55:07 user@host.(none) +1 -0
    Add another file.

ChangeSet
  1.3 05/10/06 12:55:07 user@host.(none) +1 -0
  Add another file.

  bar.txt
    1.0 05/10/06 12:55:07 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/bar.txt

ChangeSet
  1.2 05/10/06 12:53:09 user@host.(none) +1 -0
  Add sample file.

  foo.txt
    1.1 05/10/06 12:52:55 user@host.(none) +1 -0

  foo.txt
    1.0 05/10/06 12:52:55 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/foo.txt

ChangeSet
  1.1 05/10/06 12:52:28 user@host.(none) +2 -0
  Initial repository create

  BitKeeper/etc/ignore
    1.1 05/10/06 12:52:28 user@host.(none) +2 -0

  BitKeeper/etc/config
    1.1 05/10/06 12:52:28 user@host.(none) +22 -0

ChangeSet
  1.0 05/10/06 12:52:28 user@host.(none) +0 -0
  BitKeeper file /var/lib/bk/demo/dev-1.0/ChangeSet

  BitKeeper/etc/ignore
    1.0 05/10/06 12:52:28 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/BitKeeper/etc/ignore

  BitKeeper/etc/config
    1.0 05/10/06 12:52:28 user@host.(none) +0 -0
    BitKeeper file /var/lib/bk/demo/dev-1.0/BitKeeper/etc/config
";
      }

      public static string NonVerboseBitKeeperOutput()
      {
        return @"ChangeSet@1.6, 2005-10-06 12:58:40-07:00, user@host.(none)
  Remove file in subdir.

ChangeSet@1.5, 2005-10-06 12:58:11-07:00, user@host.(none)
  Another new one.

ChangeSet@1.4, 2005-10-06 12:55:38-07:00, user@host.(none)
  Remove foo.txt.

ChangeSet@1.3, 2005-10-06 12:55:07-07:00, user@host.(none)
  Add another file.

ChangeSet@1.2, 2005-10-06 12:53:09-07:00, user@host.(none)
  Add sample file.

ChangeSet@1.1, 2005-10-06 12:52:28-07:00, user@host.(none)
  Initial repository create

ChangeSet@1.0, 2005-10-06 12:52:28-07:00, user@host.(none)
  BitKeeper file /var/lib/bk/demo/dev-1.0/ChangeSet ";
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.