コード例 #1
0
        public void ForResult_NoSameValues()
        {
            var provider = new IdProvider();

            var result = Generators.CreateNewResultDto();

            var a = provider.GetForResult(result);
            var b = provider.GetForResult(result);

            Assert.AreNotEqual(a, b);
        }
コード例 #2
0
        public void ToModelSuccess()
        {
            const double tolerance = 0.01;
            var          dto       = Generators.CreateNewResultDto();
            var          model     = dto.ToModel(dto.Id, "y", "z");

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

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

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

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

            Assert.True(Helpers.AssertCollectionsAreEqual(dto.Result.TaskResults, model.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(b.Statistics, a.Statistics, tolerance) &&
                                                          Helpers.AssertCollectionsAreEqual(a.Outliers, b.Outliers, (c, d) => Helpers.AreEqual(d, c, tolerance))));


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

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

            Assert.AreEqual(dto.System.Timing.JoinOverhead, model.System.Timing.JoinOverhead);
            Assert.AreEqual(dto.System.Timing.LockOverhead, model.System.Timing.LockOverhead);
            Assert.AreEqual(dto.System.Timing.LoopOverhead, model.System.Timing.LoopOverhead);
            Assert.AreEqual(dto.System.Timing.NotifyOverhead, model.System.Timing.NotifyOverhead);
            Assert.AreEqual(dto.System.Timing.NowOverhead, model.System.Timing.NowOverhead);
            Assert.AreEqual(dto.System.Timing.SleepOverhead, model.System.Timing.SleepOverhead);
            Assert.AreEqual(dto.System.Timing.TargetTime, model.System.Timing.TargetTime);
            Assert.AreEqual(dto.System.Timing.WakeupOverhead, model.System.Timing.WakeupOverhead);
        }
コード例 #3
0
        public async Task CreateAsync_TopologyNotExist_CreatesTopology()
        {
            var id         = Guid.NewGuid().ToString("N");
            var cpuId      = Guid.NewGuid().ToString("N");
            var topologyId = Guid.NewGuid().ToString("N");

            _repoMock.Setup(r =>
                            r.CreateAsync(It.Is <ResultModel>(m => m.TimeStamp != default), It.IsAny <CancellationToken>()))
            .ReturnsAsync(id)
            .Verifiable();

            _idProvideMock.Setup(i => i.GetForCpu(It.IsAny <CpuDto>()))
            .Returns(cpuId)
            .Verifiable();

            _idProvideMock.Setup(i => i.GetForTopology(cpuId, It.IsAny <TopologyDto>()))
            .Returns(topologyId)
            .Verifiable();

            _idProvideMock.Setup(i => i.GetForResult(It.IsAny <ResultDto>()))
            .Returns(id)
            .Verifiable();

            _cpuMock.Setup(i => i.GetSingleAsync(cpuId, default))
            .ReturnsAsync(Generators.CreateNewCpuModel)
            .Verifiable();

            _topologyMock.Setup(i => i.GetSingleAsync(topologyId, default))
            .ReturnsAsync((TopologyModel)null)
            .Verifiable();

            _topologyMock.Setup(i => i.CreateAsync(It.Is <TopologyModel>(c => c.Id == topologyId), default))
            .ReturnsAsync(topologyId)
            .Verifiable();


            var service = GetService();

            var result = await service.CreateAsync(Generators.CreateNewResultDto(), default);

            Assert.AreEqual(id, result);

            VerifyMocks();
        }