コード例 #1
0
        public void From_VariousProcessorTypes_ReturnsCPU(ushort processorType, string decoded)
        {
            //Arrange
            var win32Processor = new Win32_Processor
            {
                Architecture      = 1,
                CurrentClockSpeed = 1,
                L2CacheSize       = 1,
                L3CacheSize       = 1,
                Name                      = "Model - Vendor",
                NumberOfCores             = 1,
                NumberOfLogicalProcessors = 1,
                ProcessorType             = processorType,
                Caption                   = "Caption",
                Family                    = 1,
                UpgradeMethod             = 1
            };

            //Act
            var result = CPUMapper.From(win32Processor);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.ProcessorType == decoded);
        }
コード例 #2
0
        public void From_UpgradeMethodIsNull_ReturnsCPU()
        {
            //Arrange
            var win32Processor = new Win32_Processor
            {
                Architecture      = 1,
                CurrentClockSpeed = 1,
                L2CacheSize       = 1,
                L3CacheSize       = 1,
                Name                      = "Model - Vendor",
                NumberOfCores             = 1,
                NumberOfLogicalProcessors = 1,
                ProcessorType             = 1,
                Caption                   = "Caption",
                Family                    = 1,
                UpgradeMethod             = null
            };

            //Act
            var result = CPUMapper.From(win32Processor);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Architecture == "MIPS");
            Assert.True(result.CurrentClockSpeed == win32Processor.CurrentClockSpeed);
            Assert.True(result.L2CacheSize == win32Processor.L2CacheSize);
            Assert.True(result.L3CacheSize == win32Processor.L3CacheSize);
            Assert.True(result.ModelWithVendor == "Model - Vendor");
            Assert.True(result.NumberOfCores == win32Processor.NumberOfCores);
            Assert.True(result.NumberOfLogicalProcessors == win32Processor.NumberOfLogicalProcessors);
            Assert.True(result.ProcessorType == "Other");
            Assert.True(result.Caption == "Caption");
            Assert.True(result.Family == "Other");
            Assert.True(result.UpgradeMethod == "Unknown");
        }
コード例 #3
0
        public async Task <Result <IEnumerable <CPU> > > GetPhysicalCPUsAsync()
        {
            try
            {
                var result = await Task.Run(() => _componentRepo.Get <Win32_Processor>());

                var output = result.Select(x => CPUMapper.From(x));

                return(Result <IEnumerable <CPU> > .Ok(output));
            }
            catch (Exception e)
            {
                return(Result <IEnumerable <CPU> > .Fail(e));
            }
        }