public void Can_read_the_changed_fields_from_alert_xml_block() { // Arrange var alertMessage = TestData.DummyCheckInAlertXml(); // act var actual = EventXmlHelper.GetCheckInDetails(alertMessage); // assert Assert.AreEqual("Scrum (TFVC) Changeset 62: The comment", actual.Summary); Assert.AreEqual(@"TYPHOONTFS\Richard", actual.Committer); Assert.AreEqual(@"Scrum (TFVC)", actual.TeamProject); Assert.AreEqual(@"The comment", actual.Comment); Assert.AreEqual(1, actual.FilesAdded.Count); Assert.AreEqual("NextClass.cs", actual.FilesAdded[0]); Assert.AreEqual(2, actual.FilesEdited.Count); Assert.AreEqual("ClassLibrary1.csproj", actual.FilesEdited[0]); Assert.AreEqual(1, actual.FilesDeleted.Count); Assert.AreEqual("Class1.cs", actual.FilesDeleted[0]); Assert.AreEqual(62, actual.Changeset); }
public void Notify(string eventXml, string tfsIdentityXml) { try { if (ConfigHelper.ParseOrDefault(System.Configuration.ConfigurationManager.AppSettings["LogEventsToFile"]) == true) { var logPath = ConfigHelper.GetLoggingPath(); logger.Info(string.Format("TFSEventsProcessor: DslScriptService Event being logged to [{0}]", logPath)); LoggingHelper.DumpEventToDisk(eventXml, logPath); } // Create a new Tfs helper this.iTfsProvider.UnpackIdentity(tfsIdentityXml); // work out the event type string[] argItems = null; try { var buildDetails = EventXmlHelper.GetBuildStatusChangedAlertFields(eventXml); argItems = new[] { EventTypes.BuildEvent.ToString(), buildDetails.BuildUri.ToString() }; logger.Info(string.Format( "TFSEventsProcessor: DslScriptService Event being processed for Build:{0}", buildDetails.BuildUri)); } catch (NullReferenceException) { // if it not build must be work item // Extract the required information out of the eventXml var workItemId = EventXmlHelper.GetWorkItemValue <int>( eventXml, EventXmlHelper.FieldSection.CoreFields, EventXmlHelper.FieldType.IntegerField, EventXmlHelper.ValueType.NewValue, "System.Id"); if (workItemId > 0) { argItems = new[] { EventTypes.WorkItemEvent.ToString(), workItemId.ToString() }; logger.Info( string.Format("TFSEventsProcessor: DslScriptService Event being processed for WI:{0}", workItemId)); } else { try { var checkInDetails = EventXmlHelper.GetCheckInDetails(eventXml); argItems = new[] { EventTypes.CheckInEvent.ToString(), checkInDetails.Changeset.ToString() }; logger.Info( string.Format( "TFSEventsProcessor: DslScriptService Event being processed for Checkin:{0}", checkInDetails.Changeset)); } catch (NullReferenceException) { // other event type } } } var args = new Dictionary <string, object> { { "Arguments", argItems }, }; var engine = new TFSEventsProcessor.Dsl.DslProcessor(); engine.RunScript( this.dslFolder, this.scriptFolder, GetScriptName(argItems[0], this.scriptFile), args, this.iTfsProvider, this.iEmailProvider, eventXml); } catch (Exception ex) { // using a global exception catch to make sure we don't block any threads this.DumpException(ex); } }