public void LogLineFrameData_CopyConstructor_OtherIsNull_Test()
        {
            // Act
            var copy = new LogLineFrameData(null);

            // Assert
            Assert.AreEqual(0, copy.ID);
            Assert.AreEqual(0, copy.RawFramesComplete);
            Assert.AreEqual(0, copy.RawFramesTotal);
            Assert.AreEqual(default(TimeSpan), copy.TimeStamp);
            Assert.AreEqual(default(TimeSpan), copy.Duration);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogLineFrameData"/> class.
        /// </summary>
        /// <param name="other">The other instance from which data will be copied.</param>
        public LogLineFrameData(LogLineFrameData other)
        {
            if (other == null)
            {
                return;
            }

            ID = other.ID;
            RawFramesComplete = other.RawFramesComplete;
            RawFramesTotal    = other.RawFramesTotal;
            TimeStamp         = other.TimeStamp;
            Duration          = other.Duration;
        }
Beispiel #3
0
        private static Dictionary <int, LogLineFrameData> CopyFrames(IDictionary <int, LogLineFrameData> source)
        {
            if (source == null)
            {
                return(null);
            }

            var copy = new Dictionary <int, LogLineFrameData>();

            foreach (var kvp in source)
            {
                var valueCopy = new LogLineFrameData(kvp.Value);
                copy.Add(kvp.Key, valueCopy);
            }
            return(copy);
        }
        public void LogLineFrameData_CopyConstructor_Test()
        {
            // Arrange
            var data = new LogLineFrameData
            {
                ID = 1,
                RawFramesComplete = 10000,
                RawFramesTotal    = 1000000,
                TimeStamp         = TimeSpan.FromMinutes(1),
                Duration          = TimeSpan.FromMinutes(2)
            };
            // Act
            var copy = new LogLineFrameData(data);

            // Assert
            Assert.AreEqual(data.ID, copy.ID);
            Assert.AreEqual(data.RawFramesComplete, copy.RawFramesComplete);
            Assert.AreEqual(data.RawFramesTotal, copy.RawFramesTotal);
            Assert.AreEqual(data.TimeStamp, copy.TimeStamp);
            Assert.AreEqual(data.Duration, copy.Duration);
        }
        /// <summary>
        /// Creates a new <see cref="UnitRunData"/> object from the information contained in the <see cref="UnitRun"/> object.
        /// </summary>
        protected override UnitRunData OnGetUnitRunData(UnitRun unitRun)
        {
            var unitRunData = new FahClientUnitRunData();
            var frames      = new Dictionary <int, LogLineFrameData>();

            int count = unitRun.LogLines.Count;

            for (int i = 0; i < count; i++)
            {
                var line = unitRun.LogLines[i];
                switch (line.LineType)
                {
                case LogLineType.WorkUnitWorking:
                    unitRunData.UnitStartTimeStamp = line.TimeStamp;
                    unitRunData.WorkUnitResult     = Internal.WorkUnitResult.None;
                    break;

                case LogLineType.WorkUnitFrame:
                    if (unitRunData.UnitStartTimeStamp == null)
                    {
                        unitRunData.UnitStartTimeStamp = line.TimeStamp;
                    }
                    if (line.Data != null && !(line.Data is LogLineDataParserError))
                    {
                        if (line.Data is LogLineFrameData frameData)
                        {
                            // Make a copy so UnitRunData is not holding a reference to the same
                            // WorkUnitFrameData instance as the LogLine it was sourced from.
                            var frameDataCopy = new LogLineFrameData(frameData);
                            frames.TryAdd(frameData.ID, frameDataCopy);

                            if (unitRunData.FramesObserved > 0)
                            {
                                Internal.CommonRunDataAggregator.CalculateFrameDataDuration(frameDataCopy, frames);
                            }
                        }
                        unitRunData.FramesObserved++;
                    }
                    break;

                case LogLineType.WorkUnitCoreVersion:
                    if (line.Data != null && !(line.Data is LogLineDataParserError))
                    {
                        unitRunData.CoreVersion = (string)line.Data;
                    }
                    break;

                case LogLineType.WorkUnitProject:
                    var projectData = (LogLineProjectData)line.Data;
                    unitRunData.ProjectID    = projectData.ProjectID;
                    unitRunData.ProjectRun   = projectData.ProjectRun;
                    unitRunData.ProjectClone = projectData.ProjectClone;
                    unitRunData.ProjectGen   = projectData.ProjectGen;
                    break;

                case LogLineType.WorkUnitPlatform:
                    if (line.Data != null)
                    {
                        unitRunData.Platform = (string)line.Data;
                    }
                    break;

                case LogLineType.WorkUnitCoreReturn:
                    unitRunData.WorkUnitResult = (string)line.Data;
                    switch (unitRunData.WorkUnitResult)
                    {
                    case Internal.WorkUnitResult.INTERRUPTED:
                    case Internal.WorkUnitResult.UNKNOWN_ENUM:
                        unitRunData.FramesObserved = 0;
                        break;

                    case Internal.WorkUnitResult.CORE_RESTART:
                        unitRunData.FramesObserved = 0;
                        frames.Clear();
                        break;
                    }
                    break;
                }
            }

            unitRunData.Frames = frames;
            return(unitRunData);
        }