private void CreateAll(CpuIdXmlFactory factory, string fileName) { Console.WriteLine("Instantiating: {0}", fileName); IEnumerable <ICpuId> cpus = factory.CreateAll(fileName); foreach (ICpuId cpu in cpus) { Assert.That(cpu, Is.Not.Null); CpuId.Intel.ICpuIdX86 x86cpu = cpu as CpuId.Intel.ICpuIdX86; switch (cpu.CpuVendor) { case CpuVendor.AuthenticAmd: Assert.That(x86cpu, Is.Not.Null); if (!string.IsNullOrEmpty(x86cpu.BrandString) && !x86cpu.BrandString.Equals(x86cpu.Description)) { // Used for debugging if the conversion to the brand string is correct. We only check those that // actually have a brand string. Console.WriteLine(" CPU Brand: {0}; Description: {1}", x86cpu.BrandString, x86cpu.Description); } break; case CpuVendor.GenuineIntel: Assert.That(x86cpu, Is.Not.Null); break; } } }
public void IntelCreateFromXmlConstructorFile() { CpuIdXmlFactory factory = new CpuIdXmlFactory(MultiCpu); ICpuId cpu = factory.Create(); Assert.That(cpu, Is.Not.Null); Assert.That(cpu.Description, Is.EqualTo("Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz")); }
public void IntelCreateFromXmlFileProperty() { CpuIdXmlFactory factory = new CpuIdXmlFactory { FileName = MultiCpu }; ICpuId cpu = factory.Create(); Assert.That(cpu, Is.Not.Null); Assert.That(cpu.Description, Is.EqualTo("Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz")); }
public void IntelCreateAllFromXmlConstructorFile() { CpuIdXmlFactory factory = new CpuIdXmlFactory(MultiCpu); IEnumerable <ICpuId> cpus = factory.CreateAll(); Assert.That(cpus, Is.Not.Null); Assert.That(cpus.Count(), Is.EqualTo(8)); foreach (ICpuId id in cpus) { Assert.That(id.Description, Is.EqualTo("Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz")); } }
public static int Main() { ICpuIdFactory cpuFactory = new CpuIdFactory(); ICpuId firstCpu = cpuFactory.Create(); IEnumerable <ICpuId> cpus = cpuFactory.CreateAll(); string fileName; if (firstCpu is CpuId.Intel.ICpuIdX86 x86cpu) { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0}{1:X07} ({2}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, Environment.MachineName); } else { fileName = string.Format("{0}{1:X07} ({2}, {3}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, firstCpu.Description, Environment.MachineName); } } else { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0} ({1}).xml", firstCpu.VendorId, Environment.MachineName); } else { fileName = string.Format("{0} ({1}, {2}).xml", firstCpu.VendorId, firstCpu.Description, Environment.MachineName); } } try { CpuIdXmlFactory.Save(fileName, cpus); Console.WriteLine("Wrote output to: {0}", fileName); return(0); } catch (Exception ex) { Console.WriteLine("Error writing to: {0}", fileName); Console.WriteLine(" -> {0}", ex.Message); return(1); } }
private void CreateAll(params string[] path) { string directory = Path.Combine(path); string fullPath; if (Path.IsPathRooted(directory)) { fullPath = directory; } else { fullPath = Path.Combine(Deploy.TestDirectory, "TestResources", directory); } CpuIdXmlFactory factory = new CpuIdXmlFactory(); string[] files = Directory.GetFiles(fullPath, "*.xml", SearchOption.AllDirectories); foreach (string file in files) { CreateAll(factory, file); } }