コード例 #1
0
 public void SetupModification(Modification[] modifications)
 {
     foreach (Modification mod in modifications)
     {
         mod.Url = String.Format(_url, mod.FolderName.Length == 0 ? mod.FileName : mod.FolderName + "/" + mod.FileName);
     }
 }
コード例 #2
0
        public Modification[] Parse(TextReader history, DateTime from, DateTime to)
        {
            var modifications = new List<Modification>();
            var document = XDocument.Load(history);
            var fromDate = from.ToString("s");
            var toDate = to.ToString("s");
            foreach (XElement change in document.Descendants("change"))
            {
                var date = DateTime.Parse(
                    change.Attribute("date").Value);
                if ((date >= from) &&
                    (date <= to))
                {
                    var modification = new Modification
                    {
                        FileName = change.Attribute("file").Value,
                        ModifiedTime = date,
                        FolderName = change.Attribute("folder").Value,
                        Type = change.Attribute("type").Value
                    };
                    modifications.Add(modification);
                }
            }

            return modifications.ToArray();
        }
コード例 #3
0
		public void ShouldNotAcceptModificationsWithNullFolder()
		{
			Modification modification = new Modification();
			PathFilter filter = new PathFilter();
			filter.Pattern = "*.*";
			Assert.IsFalse(filter.Accept(modification));
		}
コード例 #4
0
		public void ShouldCheckModificationsUntilThereAreNoModsInModificationDelay()
		{
			quietPeriod.ModificationDelaySeconds = 45;		

			// last build was at 12:01:00, current build is at 12:02:00
			
			// with a modification just at 12:01:30...
			Modification[] newMods = new Modification[] { CreateModificationAtTime(12, 01, 30) };
			
			// ...should wait for 15 seconds so that the 45 second delay completes (at 12:02:15)
			mockSourceControl.ExpectAndReturn("GetModifications", newMods, lastBuild, thisBuild);
			mockDateTimeProvider.Expect("Sleep", TimeSpan.FromSeconds(15));
			mockDateTimeProvider.ExpectAndReturn("Now", CreateDateTime(12, 02, 15));

			// After this time it should ask for modifications again.  Introduce a new modification at 12:02:10, meaning that the ealiest a build can start is at 12:02:55
			//  i.e. 40 seconds from the time of the current build (12:02:15)
			newMods = new Modification[] {newMods[0], CreateModificationAtTime(12, 02, 10)};		
			mockSourceControl.ExpectAndReturn("GetModifications", newMods, lastBuild, IntegrationResultMother.CreateSuccessful(CreateDateTime(12, 02, 15)));
			mockDateTimeProvider.Expect("Sleep", TimeSpan.FromSeconds(40));
			mockDateTimeProvider.ExpectAndReturn("Now", CreateDateTime(12, 02, 55));
			mockSourceControl.ExpectAndReturn("GetModifications", newMods, lastBuild, IntegrationResultMother.CreateSuccessful(CreateDateTime(12, 02, 55)));

			Modification[] actualMods = quietPeriod.GetModifications((ISourceControl) mockSourceControl.MockInstance, lastBuild, thisBuild);

			Assert.AreEqual(newMods, actualMods);
		}
コード例 #5
0
		public void ShouldRejectModificationsWithNullComments()
		{
			Modification modification = new Modification();
            CommentFilter filter = new CommentFilter();
			filter.Pattern = ".*";
			Assert.IsFalse(filter.Accept(modification), "Should not have matched but did.");
		}
コード例 #6
0
		public void ShouldFilterSpecifiedAction()
		{
			Modification mod = new Modification();
			mod.Type = "Created";

			filter.Actions = new string[] {"Created"};
			Assert.IsTrue(filter.Accept(mod), "Action not filtered");
		}
コード例 #7
0
		public void ShouldFilterSpecifiedUser()
		{
			Modification mod = new Modification();
			mod.UserName = "******";

			filter.UserNames = new string[] { "bob" };
			Assert.IsTrue(filter.Accept(mod));
		}
コード例 #8
0
 public void ShouldRejectModificationsWithMatchingComments()
 {
     Modification modification = new Modification();
     modification.Comment = "This is a comment.";
     CommentFilter filter = new CommentFilter();
     filter.Pattern = ".* is not a .*";
     Assert.IsFalse(filter.Accept(modification), "Should not have matched but did.");
 }
コード例 #9
0
		public void GetModificationsDoesNotCreateLabelWhenThereAreNoModifications()
		{
			ProcessResult result = new ProcessResult("",string.Empty, 0, false);
			Modification[] emptyArray = new Modification[0];
			_historyParser.SetupResult("Parse", emptyArray, typeof(TextReader), typeof(DateTime), typeof(DateTime));
			_executor.ExpectAndReturn("Execute", result, new IsTypeOf(typeof(ProcessInfo)));
			_executor.ExpectNoCall("Execute", typeof(ProcessInfo));

			_vss.GetModifications(IntegrationResultMother.CreateSuccessful(DateTime.Now), IntegrationResultMother.CreateSuccessful(DateTime.Now));
		}
コード例 #10
0
		public void ParseUsernameAndUKDate()
		{
			Modification mod = new Modification();
			string line = "foo\r\nUser: Admin        Date:  16/9/02   Time:  22:40\r\n";
            CheckInParser myParser = new CheckInParser(line, new VssLocale(new CultureInfo("en-GB")));
            myParser.ParseUsernameAndDate(mod);

			Assert.AreEqual("Admin", mod.UserName);
			Assert.AreEqual(new DateTime(2002, 9, 16, 22, 40, 0), mod.ModifiedTime);
		}
コード例 #11
0
		public void CanAssignFileInfoWithNoPath()
		{
			const string file = "context.js";
			Modification modification = new Modification();

			parser.AssignFileInfo( modification, file );

			Assert.AreEqual( string.Empty, modification.FolderName );
			Assert.AreEqual( file, modification.FileName );
		}
コード例 #12
0
        public AccuRevMotherWindows()
        {
            historyOutputReader = new StringReader(historyOutputDataWindows);

            /// The date ranges.
            oldestHistoryModification = DateTime.Parse("2006/11/22 11:10:44");
            newestHistoryModification = DateTime.Parse("2006/11/22 11:11:00");

            historyOutputModifications = new Modification[5];

            historyOutputModifications[0] = new Modification();
            historyOutputModifications[0].ChangeNumber = "12245";
            historyOutputModifications[0].Comment = "New Project for accessing SICS/nt web services";
            historyOutputModifications[0].FileName = "AssemblyInfo.cs";
            historyOutputModifications[0].FolderName = @"Dev\Server\Interface\Properties\";
            historyOutputModifications[0].ModifiedTime = new DateTime(2006,11,22,11,11,00);
            historyOutputModifications[0].Type = "add";
            historyOutputModifications[0].UserName = "******";

            historyOutputModifications[1] = new Modification();
            historyOutputModifications[1].ChangeNumber = "12244";
            historyOutputModifications[1].Comment = "New Project for accessing web services";
            historyOutputModifications[1].FileName = "Interface";
            historyOutputModifications[1].FolderName = @"Dev\Server\";
            historyOutputModifications[1].ModifiedTime = new DateTime(2006,11,22,11,10,44);
            historyOutputModifications[1].Type = "add";
            historyOutputModifications[1].UserName = "******";

            historyOutputModifications[2] = new Modification();
            historyOutputModifications[2].ChangeNumber = "12244";
            historyOutputModifications[2].Comment = "New Project for accessing web services";
            historyOutputModifications[2].FileName = "App.config";
            historyOutputModifications[2].FolderName = @"Dev\Server\Interface\";
            historyOutputModifications[2].ModifiedTime = new DateTime(2006, 11, 22, 11, 10, 44);
            historyOutputModifications[2].Type = "add";
            historyOutputModifications[2].UserName = "******";

            historyOutputModifications[3] = new Modification();
            historyOutputModifications[3].ChangeNumber = "12244";
            historyOutputModifications[3].Comment = "New Project for accessing web services";
            historyOutputModifications[3].FileName = "CommonTypes.cs";
            historyOutputModifications[3].FolderName = @"Dev\Server\Interface\";
            historyOutputModifications[3].ModifiedTime = new DateTime(2006, 11, 22, 11, 10, 44);
            historyOutputModifications[3].Type = "add";
            historyOutputModifications[3].UserName = "******";

            historyOutputModifications[4] = new Modification();
            historyOutputModifications[4].ChangeNumber = "12244";
            historyOutputModifications[4].Comment = "New Project for accessing web services";
            historyOutputModifications[4].FileName = "Connection.cs";
            historyOutputModifications[4].FolderName = @"Dev\Server\Interface\";
            historyOutputModifications[4].ModifiedTime = new DateTime(2006, 11, 22, 11, 10, 44);
            historyOutputModifications[4].Type = "add";
            historyOutputModifications[4].UserName = "******";
        }
コード例 #13
0
		public void ShouldBuildValidUrls()
		{
			HgWebUrlBuilder hgweb = new HgWebUrlBuilder();
			hgweb.Url = "http://selenic.com/hg/index.cgi/";
			Modification[] modifications = new Modification[] {new Modification()};
			modifications[0].Version = "4a064e1977f8";
			hgweb.SetupModification(modifications);

			Assert.That(modifications[0].Url, Is.Not.Null);
			Assert.That(modifications[0].Url, Is.EqualTo("http://selenic.com/hg/index.cgi/rev/4a064e1977f8"));
		}
コード例 #14
0
		protected Modification[] CreateModifications()
		{
			Modification[] testModifications = new Modification[]
				{
					new Modification(), new Modification(), new Modification()
				};
			testModifications[0].ChangeNumber = "100";
			testModifications[1].ChangeNumber = "2000";
			testModifications[2].ChangeNumber = "30000";
			return (testModifications);
		}
コード例 #15
0
		private void AssertModification(Modification mod, int changeNumber, string revision, string file, string folder, DateTime modifiedTime, string type, string email, string username, string comment)
		{
			Assert.AreEqual(changeNumber.ToString(), mod.ChangeNumber);
			Assert.AreEqual(file, mod.FileName);
			Assert.AreEqual(folder, mod.FolderName);
			Assert.AreEqual(modifiedTime, mod.ModifiedTime);
			Assert.AreEqual(type, mod.Type);
			Assert.AreEqual(email, mod.EmailAddress);
			Assert.AreEqual(username, mod.UserName);
			Assert.AreEqual(comment, mod.Comment);
			Assert.AreEqual(revision, mod.Version);
		}
コード例 #16
0
        public void ModificationsAreComparedByModifiedDatetime()
        {
            Modification alpha = new Modification();
            alpha.ModifiedTime = new DateTime(1975, 3, 3);

            Modification beta = new Modification();
            alpha.ModifiedTime = new DateTime(1961, 3, 3);

            Assert.IsTrue(alpha.CompareTo(beta) > 0, string.Format("expected alpha greater than beta {0}", alpha.CompareTo(beta)));
            Assert.IsTrue(alpha.CompareTo(alpha) == 0, string.Format("expected alpha-beta equality {0}", alpha.CompareTo(beta)));
            Assert.IsTrue(beta.CompareTo(alpha) < 0, string.Format("expected alpha less than beta {0}", alpha.CompareTo(beta)));
        }
コード例 #17
0
		public void ParseUsernameAndUSDate()
		{
			Modification mod = new Modification();
			
			string line = "foo\r\nUser: Admin        Date:  9/16/02   Time:  2:40p\r\n";
			CheckInParser parser = new CheckInParser(line, new VssLocale(new CultureInfo("en-US")));
			parser.ParseUsernameAndDate(mod);
			string expectedUsername = "******";
			DateTime expectedDate = new DateTime(2002, 09, 16, 14, 40, 0);
			Assert.AreEqual(expectedUsername, mod.UserName);
			Assert.AreEqual(expectedDate, mod.ModifiedTime);
		}
コード例 #18
0
        public void AppendModifications()
        {
            WorkflowResult result = new WorkflowResult();
            Modification mod1 = new Modification();
            Modification mod2 = new Modification();
            result.Modifications = new Modification[] { mod1 };
            result.Modifications = new Modification[] { mod2 };

            Assert.AreEqual(2, result.Modifications.Length);
            Assert.AreEqual(mod1, result.Modifications[0]);
            Assert.AreEqual(mod2, result.Modifications[1]);
        }
コード例 #19
0
		public void CanAssignFileInfo()
		{
			const string path = @"D:\CCase\ppunjani_view\RefArch\tutorial\wwhdata\common";
			const string file = "context.js";
			const string fullPath = path + "\\" + file;
			Modification modification = new Modification();

			parser.AssignFileInfo( modification, fullPath );

			Assert.AreEqual( path, modification.FolderName );
			Assert.AreEqual( file, modification.FileName );
		}
コード例 #20
0
        public void CommentWithIssueNumberOnly()
        {
            Modification[] mods = new Modification[1];
            mods[0] = new Modification();
            mods[0].FolderName = "/trunk";
            mods[0].FileName = "nant.bat";
            mods[0].ChangeNumber = "3";
            mods[0].Comment = "5000";

            RegExIssueTrackerUrlBuilder regexIssue = CreateBuilder();
            regexIssue.SetupModification(mods);

            Assert.IsNull(mods[0].IssueUrl);
        }
コード例 #21
0
        public void CommentWithPrefixAndProjectPrefixAndIssueNumber()
        {
            Modification[] mods = new Modification[1];
            mods[0] = new Modification();
            mods[0].FolderName = "/trunk";
            mods[0].FileName = "nant.bat";
            mods[0].ChangeNumber = "3";
            mods[0].Comment = "some random text CCNET-5000 and the issue description";

            RegExIssueTrackerUrlBuilder regexIssue = CreateBuilder();
            regexIssue.SetupModification(mods);

            Assert.AreEqual(ExpectedUrl, mods[0].IssueUrl);
        }
コード例 #22
0
        public void CommentWithProjectPrefixAndIssueNumberAndText()
        {
            Modification[] mods = new Modification[1];
            mods[0] = new Modification();
            mods[0].FolderName = "/trunk";
            mods[0].FileName = "nant.bat";
            mods[0].ChangeNumber = "3";
            mods[0].Comment= "CCNET-5000 blablabla";

            DefaultIssueTrackerUrlBuilder defaultIssue = CreateBuilder();
            defaultIssue.SetupModification(mods);

            string url = String.Format(UrlFromConfigFile, 5000);
            Assert.AreEqual(url, mods[0].IssueUrl);
        }
コード例 #23
0
        public void ParseMemberInfo()
        {
            Modification modification = new Modification();
            MksHistoryParser parser = new MksHistoryParser();
            parser.ParseMemberInfoAndAddToModification(modification, new StringReader(MEMBER_INFO));

            DateTime modifiedTimeWithLocalTimeZone = DateTime.Parse("2009-10-16T18:07:08");
            DateTime modifiedTimeWithCorrectTimeZoneInformation = modification.ModifiedTime;
            TimeSpan actualOffsetAtModifiedTime = modifiedTimeWithCorrectTimeZoneInformation.Subtract(modifiedTimeWithLocalTimeZone);

            TimeSpan expectedOffsetAtModifiedTime = TimeZone.CurrentTimeZone.GetUtcOffset(modifiedTimeWithLocalTimeZone);

            Assert.AreEqual("Test", modification.UserName);
            Assert.AreEqual(expectedOffsetAtModifiedTime, actualOffsetAtModifiedTime, "Date was not parsed with correct time zone offset.");
            Assert.AreEqual("Test Comment", modification.Comment);
        }
コード例 #24
0
 /// <summary>
 /// Retrieves the change number of the last modification.
 /// </summary>
 /// <param name="modifications">The modifications to check.</param>
 /// <returns>The last change number if there are any changes, null otherwise.</returns>
 /// <remarks>
 /// Since ChangeNumbers are no longer numbers, this will return null if there are no 
 /// modifications.
 /// </remarks>
 public static string GetLastChangeNumber(Modification[] modifications)
 {
     var lastModification = new Modification
     {
         ModifiedTime = DateTime.MinValue,
         ChangeNumber = null
     };
     foreach (Modification modification in modifications)
     {
         if (modification.ModifiedTime > lastModification.ModifiedTime)
         {
             lastModification = modification;
         }
     }
     return lastModification.ChangeNumber;
 }
コード例 #25
0
		public void ParseCreatedModification()
		{
			string entry = EntryWithSingleLineComment();
			
			Modification expected = new Modification();
			expected.Comment = "added subfolder";
			expected.UserName = "******";
			expected.ModifiedTime = new DateTime(2002, 9, 16, 14, 41, 0);
			expected.Type = "Created";
			expected.FileName = "[none]";
			expected.FolderName = "plant";

			Modification[] actual = parser.ParseModifications(makeArray(entry));
			Assert.IsNotNull(actual, "expected a mod");
			Assert.AreEqual(0, actual.Length, "created should not have produced a modification");
		}
コード例 #26
0
        public void ShouldNotFilterSpecifiedModWithOneFilterThatAccepts()
        {
            Modification mod = new Modification();
            mod.Type = "Delete";
            mod.UserName = "******";

            ActionFilter aFilter = new ActionFilter();
            UserFilter uFilter = new UserFilter();


            aFilter.Actions = new string[] { "Created" };
            uFilter.UserNames = new string[] { "bob" };

            filter.Filters = new IModificationFilter[] { aFilter, uFilter };

            Assert.IsFalse(filter.Accept(mod), "Modifcation was filtered");
        }
コード例 #27
0
		public void ParsingSingleLogMessageProducesOneModification()
		{
			Modification[] modifications = svn.Parse(new StringReader(oneEntryLogXml), oldestEntry, newestEntry);

			Assert.AreEqual(1, modifications.Length);

			Modification expected = new Modification();
			expected.Type = "Added";
			expected.FileName = "addedfile.txt";
			expected.FolderName = "/foo";
			expected.ModifiedTime = CreateDate("2003-12-12T16:48:51Z");
			expected.ChangeNumber = "4";
			expected.UserName =string.Empty;
			expected.Comment = "i added a file";

			Assert.AreEqual(expected, modifications[0]);
		}
コード例 #28
0
        public void AnalyzeModifications()
        {
            Modification[] expected = new Modification[1];
            expected[0] = new Modification();
            expected[0].Comment = @"Added new labels.";
            expected[0].EmailAddress = null;
            expected[0].Version = "1.4";
            expected[0].FileName = @"ChessViewer.java-arc";
            expected[0].FolderName = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            expected[0].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            expected[0].Type = "Checked in";
            expected[0].UserName = "******";

            Modification[] actual = PvcsHistoryParser.AnalyzeModifications(GetExpectedModificationsForAnalyze());

            CustomAssertion.AssertEqualArrays(actual, expected);
        }
コード例 #29
0
        public void ShouldFilterSpecifiedModification()
        {
            Modification mod = new Modification();
            mod.Type = "Created";
            mod.UserName = "******";

            ActionFilter aFilter = new ActionFilter();
            UserFilter uFilter = new UserFilter();


            aFilter.Actions = new string[] { "Created" };
            uFilter.UserNames = new string[] { "bob" };

            filter.Filters = new IModificationFilter[] { aFilter, uFilter };

            Assert.IsTrue(filter.Accept(mod), "Modifcation not filtered");
        }
コード例 #30
0
        private Modification[] GetExpectedModificationsForAnalyze()
        {
            Modification[] mod = new Modification[4];
            mod[0] = new Modification();
            mod[0].Comment = @"Added new labels.";
            mod[0].EmailAddress = null;
            mod[0].Version = "1.2";
            mod[0].FileName = @"ChessViewer.java-arc";
            mod[0].FolderName = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            mod[0].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            mod[0].Type = "Checked in";
            mod[0].UserName = "******";

            mod[1] = new Modification();
            mod[1].Comment = @"Added new labels.";
            mod[1].EmailAddress = null;
            mod[1].Version = "1.1";
            mod[1].FileName = @"ChessViewer.java-arc";
            mod[1].FolderName = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            mod[1].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            mod[1].Type = "Checked in";
            mod[1].UserName = "******";

            mod[2] = new Modification();
            mod[2].Comment = @"Added new labels.";
            mod[2].EmailAddress = null;
            mod[2].Version = "1.4";
            mod[2].FileName = @"ChessViewer.java-arc";
            mod[2].FolderName = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            mod[2].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            mod[2].Type = "Checked in";
            mod[2].UserName = "******";

            mod[3] = new Modification();
            mod[3].Comment = @"Added new labels.";
            mod[3].EmailAddress = null;
            mod[3].Version = "1.3";
            mod[3].FileName = @"ChessViewer.java-arc";
            mod[3].FolderName = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            mod[3].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            mod[3].Type = "Checked in";
            mod[3].UserName = "******";

            return mod;
        }