public void CopyCommentToClipboardMoreThanOneCommentTest() { // Arrange TimeLineItem tl1 = new TimeLineItem() { ProjectName = "AT", StartTime = DateTime.Parse( "1:00 pm" ), EndTime = DateTime.Parse( "2:00 pm" ), Comment = "CMT1" }; TimeLineItem tl2 = new TimeLineItem() { ProjectName = "RE", StartTime = DateTime.Parse( "2:00 pm" ), EndTime = DateTime.Parse( "3:00 pm" ) }; TimeLineItem tl3 = new TimeLineItem() { ProjectName = "AT", StartTime = DateTime.Parse( "3:00 pm" ), EndTime = DateTime.Parse( "4:00 pm" ), Comment = "CMT2" }; List<TimeLineItem> items = new List<TimeLineItem>(); items.Add( tl1 ); items.Add( tl2 ); items.Add( tl3 ); // Act TimeEntryViewModel sut = new TimeEntryViewModel(); sut.TimeLineItems = items; sut.CreateTimeSummaryLists(); sut.CopyCommentToClipboardCommandOnExecute( "AT" ); System.Threading.Thread.Sleep( 500 ); string results = System.Windows.Forms.Clipboard.GetText(); // Assert Assert.AreEqual( tl1.Comment + "\r\n" + tl3.Comment, results ); }
public void CreateTimeSummaryGroupsTest() { // Arrange TimeLineItem tl1 = new TimeLineItem() { ProjectName = "AT", StartTime = DateTime.Parse( "1:00 pm" ), EndTime = DateTime.Parse( "2:00 pm" ) }; TimeLineItem tl2 = new TimeLineItem() { ProjectName = "RE", StartTime = DateTime.Parse( "2:00 pm" ), EndTime = DateTime.Parse( "3:00 pm" ) }; TimeLineItem tl3 = new TimeLineItem() { ProjectName = "AT", StartTime = DateTime.Parse( "3:00 pm" ), EndTime = DateTime.Parse( "4:00 pm" ) }; List<TimeLineItem> items = new List<TimeLineItem>(); items.Add( tl1 ); items.Add( tl2 ); items.Add( tl3 ); // Act TimeEntryViewModel sut = new TimeEntryViewModel(); sut.TimeLineItems = items; sut.CreateTimeSummaryLists(); // Assert Assert.AreEqual( 2, sut.TimeSummaryItems.Count ); }
public void PasteAndParseCommandTest() { // Arrange (Get some initial data into the app) string testComment = "TestComment"; TimeLineItem tl1 = new TimeLineItem() { ProjectName = "AT", StartTime = DateTime.Parse( "1:00 pm" ), EndTime = DateTime.Parse( "2:00 pm" ), Comment = testComment }; List<TimeLineItem> items = new List<TimeLineItem>(); items.Add( tl1 ); TimeEntryViewModel sut = new TimeEntryViewModel(); sut.TimeLineItems = items; sut.CreateTimeSummaryLists(); sut.CopyCommentToClipboardCommandOnExecute( "AT" ); // Arrange (Here is our new data to paste in and parse) System.Windows.Forms.Clipboard.SetData( "Text", "10:15 - 11 DM Eric's Weekly\r\n11-12 AT Email" ); sut.PasteAndParseCommand.Execute( null ); // Assert Assert.AreEqual( 2, sut.TimeSummaryItems.Count ); }
public static TimeLineItem Parse( string timeLineEntry ) { logger.Info( string.Format( "timeLineEntry: '{0}'", timeLineEntry ) ); Regex timeEntryRegEx = new Regex( TimeLineEntryPattern ); Match m = timeEntryRegEx.Match( timeLineEntry ); if ( m.Success ) { logger.Info( "Match Success" ); // The user may have only entered 8 as the time and not 8:00. Until I can figure out how to do that in the DateTime.Parse // method just do a low tech convert here. string startTime = m.Groups[ StartTimeGroup ].Value; string endTime = m.Groups[ EndTimeGroup ].Value; string projectName = m.Groups[ ProjectGroup ].Value; string comment = m.Groups[ CommentGroup ].Value; logger.Info( string.Format( "startTime: '{0}'", startTime ) ); logger.Info( string.Format( "endTime: '{0}'", endTime ) ); logger.Info( string.Format( "projectName: '{0}'", projectName ) ); logger.Info( string.Format( "comment: '{0}'", comment ) ); startTime = TimeUtilities.AddMinutesField( startTime ); endTime = TimeUtilities.AddMinutesField( endTime ); // if neither time is military time then we need to default am and pm if ( ! TimeUtilities.IsMilitaryTime( startTime ) && ! TimeUtilities.IsMilitaryTime( endTime ) ) { TimeUtilities.DefaultAMorPM( ref startTime, ref endTime ); } TimeLineItem tli = new TimeLineItem() { StartTime = DateTime.Parse( startTime ), EndTime = DateTime.Parse( endTime ), ProjectName = projectName, Comment = comment.Trim() }; logger.Info( tli.ToString() ); return tli; } else throw new FormatException( "String was not recognized as a valid TimeLineItem." ); }