/// <summary> /// Initializes a new instance of the <see cref="TimingIntervalHelper"/> class. /// </summary> /// <param name="diagnostics">The object that provides access to the system wide diagnostics.</param> /// <param name="timingStorage">The object that generates reports for a stored interval.</param> /// <param name="collection">The object that stores the generated reports.</param> /// <param name="reportTransformer">The function which transforms a report into a string.</param> /// <param name="description">The description for the current interval.</param> public TimingIntervalHelper( SystemDiagnostics diagnostics, IGenerateTimingReports timingStorage, TimingReportCollection collection, Func <TimingReport, string> reportTransformer, string description) { { Debug.Assert(diagnostics != null, "The diagnostics object should not be a null reference."); Debug.Assert(timingStorage != null, "The storage object should not be a null reference."); Debug.Assert(collection != null, "The collection object should not be a null reference."); Debug.Assert(reportTransformer != null, "The report transformer object should not be a null reference."); Debug.Assert(!string.IsNullOrWhiteSpace(description), "The description string should not be a null reference or an empty string."); } m_Storage = timingStorage; m_Collection = collection; m_Transformer = reportTransformer; m_Interval = (ITimerInterval)diagnostics.Profiler.Measure(BaseConstants.TimingGroup, description); }
public void Add() { var report = new Mock <IProfilingTimeReport>(); var collection = new TimingReportCollection(); collection.CollectionChanged += (s, e) => { Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action); Assert.AreEqual(1, e.NewItems.Count); Assert.IsNull(e.OldItems); Assert.AreSame(report.Object, e.NewItems[0]); }; collection.Add(report.Object); Assert.That( collection, Is.EquivalentTo( new List <IProfilingTimeReport> { report.Object, })); }