public void ForCpu_Success() { var provider = new IdProvider(); var cpu = Generators.CreateNewCpuModel().ToDto(); Assert.AreEqual($"{cpu.Vendor}_{cpu.Brand}_{string.Join("_", cpu.AdditionalInfo.Values)}", provider.GetForCpu(cpu)); }
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); }
public void ForCpu_DoNotChangeWhenValueChanges() { var provider = new IdProvider(); var cpu = Generators.CreateNewCpuModel().ToDto(); var original = provider.GetForCpu(cpu); Assert.AreEqual(original, provider.GetForCpu(cpu)); cpu.Caches = new List <CpuCacheDto>(); Assert.AreEqual(original, provider.GetForCpu(cpu)); cpu.Frequency = cpu.Frequency + 1; Assert.AreEqual(original, provider.GetForCpu(cpu)); cpu.Smt = !cpu.Smt; Assert.AreEqual(original, provider.GetForCpu(cpu)); cpu.Features = new List <string>(); Assert.AreEqual(original, provider.GetForCpu(cpu)); }