Esempio n. 1
0
        public void ToDto_Success()
        {
            const double tolerance = 0.01;
            var          model     = Generators.CreateNewResultModel(Guid.NewGuid().ToString("N"));
            var          dto       = model.ToDto(Generators.CreateNewCpuModel(), Generators.CreateNewTopology());

            Assert.AreEqual(model.Id, dto.Id);
            Assert.AreEqual(model.TimeStamp, dto.TimeStamp);

            Assert.True(Helpers.AssertCollectionsAreEqual(model.Affinity, dto.Affinity, (a, b) => a == b));

            Assert.AreEqual(model.Elpida.Compiler.Name, dto.Elpida.Compiler.Name);
            Assert.AreEqual(model.Elpida.Compiler.Version, dto.Elpida.Compiler.Version);
            Assert.AreEqual(model.Elpida.Version.Build, dto.Elpida.Version.Build);
            Assert.AreEqual(model.Elpida.Version.Major, dto.Elpida.Version.Major);
            Assert.AreEqual(model.Elpida.Version.Minor, dto.Elpida.Version.Minor);
            Assert.AreEqual(model.Elpida.Version.Revision, dto.Elpida.Version.Revision);

            Assert.AreEqual(model.Result.Name, dto.Result.Name);

            Assert.True(Helpers.AssertCollectionsAreEqual(model.Result.TaskResults, dto.Result.TaskResults,
                                                          (a, b) => a.Name == b.Name &&
                                                          a.Description == b.Description &&
                                                          a.Suffix == b.Suffix &&
                                                          Math.Abs(a.Time - b.Time) < tolerance &&
                                                          a.Type == b.Type &&
                                                          Math.Abs(a.Value - b.Value) < tolerance &&
                                                          a.InputSize == b.InputSize &&
                                                          Helpers.AreEqual(a.Statistics, b.Statistics, tolerance) &&
                                                          Helpers.AssertCollectionsAreEqual(a.Outliers, b.Outliers, (c, d) => Helpers.AreEqual(c, d, tolerance))));


            Assert.AreEqual(model.System.Memory.PageSize, dto.System.Memory.PageSize);
            Assert.AreEqual(model.System.Memory.TotalSize, dto.System.Memory.TotalSize);

            Assert.AreEqual(model.System.Os.Category, dto.System.Os.Category);
            Assert.AreEqual(model.System.Os.Name, dto.System.Os.Name);
            Assert.AreEqual(model.System.Os.Version, dto.System.Os.Version);


            Assert.AreEqual(model.System.Timing.JoinOverhead, dto.System.Timing.JoinOverhead);
            Assert.AreEqual(model.System.Timing.LockOverhead, dto.System.Timing.LockOverhead);
            Assert.AreEqual(model.System.Timing.LoopOverhead, dto.System.Timing.LoopOverhead);
            Assert.AreEqual(model.System.Timing.NotifyOverhead, dto.System.Timing.NotifyOverhead);
            Assert.AreEqual(model.System.Timing.NowOverhead, dto.System.Timing.NowOverhead);
            Assert.AreEqual(model.System.Timing.SleepOverhead, dto.System.Timing.SleepOverhead);
            Assert.AreEqual(model.System.Timing.TargetTime, dto.System.Timing.TargetTime);
            Assert.AreEqual(model.System.Timing.WakeupOverhead, dto.System.Timing.WakeupOverhead);
        }
Esempio n. 2
0
        public void ForTopology_ValueChanges()
        {
            var provider = new IdProvider();

            var cpuId = "LOLOL";

            var topology = Generators.CreateNewTopology().ToDto();;

            var original = provider.GetForTopology(cpuId, topology);

            Assert.AreEqual(original, provider.GetForTopology(cpuId, topology));

            topology.TotalDepth = topology.TotalDepth + 1;
            Assert.AreNotEqual(original, provider.GetForTopology(cpuId, topology));

            topology.TotalLogicalCores = topology.TotalLogicalCores + 1;
            Assert.AreNotEqual(original, provider.GetForTopology(cpuId, topology));

            topology.TotalPhysicalCores = topology.TotalPhysicalCores + 1;
            Assert.AreNotEqual(original, provider.GetForTopology(cpuId, topology));

            topology.Root.Name = $"{topology.Root.Name }sdfds";
            Assert.AreNotEqual(original, provider.GetForTopology(cpuId, topology));
        }