Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProfileModel"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="storage">The object that stores all the known timing reports.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="storage"/> is <see langword="null" />.
        /// </exception>
        public ProfileModel(IContextAware context, TimingReportCollection storage)
            : base(context)
        {
            {
                Lokad.Enforce.Argument(() => storage);
            }

            m_Storage        = storage;
            m_ReadonlySource = CollectionViewSource.GetDefaultView(m_Storage);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProfileModel"/> class.
        /// </summary>
        /// <param name="context">The context that is used to execute actions on the UI thread.</param>
        /// <param name="storage">The object that stores all the known timing reports.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="storage"/> is <see langword="null" />.
        /// </exception>
        public ProfileModel(IContextAware context, TimingReportCollection storage)
            : base(context)
        {
            {
                Lokad.Enforce.Argument(() => storage);
            }

            m_Storage = storage;
            m_ReadonlySource = CollectionViewSource.GetDefaultView(m_Storage);
        }
Example #3
0
        public void Create()
        {
            var context = new Mock<IContextAware>();
            var collection = new TimingReportCollection();

            var report = new Mock<IProfilingTimeReport>();
            collection.Add(report.Object);

            var model = new ProfileModel(context.Object, collection);
            Assert.That(
                model.Results.Cast<IProfilingTimeReport>(),
                Is.EquivalentTo(collection));
        }
Example #4
0
        public void Create()
        {
            var context    = new Mock <IContextAware>();
            var collection = new TimingReportCollection();

            var report = new Mock <IProfilingTimeReport>();

            collection.Add(report.Object);

            var model = new ProfileModel(context.Object, collection);

            Assert.That(
                model.Results.Cast <IProfilingTimeReport>(),
                Is.EquivalentTo(collection));
        }
        /// <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,
                    }));
        }