public void From_ParameterIsNull_ThrowsNullReferenceException() { //Arrange Win32_PhysicalMemory win32PhysicalMemory = null; //Act //Assert Assert.Throws <NullReferenceException>(() => DDRMapper.From(win32PhysicalMemory)); }
public async Task <Result <IEnumerable <DDR> > > GetPhysicalDDRsAsync() { try { var result = await Task.Run(() => _componentRepo.Get <Win32_PhysicalMemory>()); var output = result.Select(x => DDRMapper.From(x)).ToList(); return(Result <IEnumerable <DDR> > .Ok(output)); } catch (Exception e) { return(Result <IEnumerable <DDR> > .Fail(e)); } }
public void From_CapacityIsNull_ReturnsDDR() { //Arrange var win32PhysicalMemory = new Win32_PhysicalMemory { Capacity = null, ConfiguredClockSpeed = 2000, FormFactor = 1, Manufacturer = "Manufacturer" }; //Act var result = DDRMapper.From(win32PhysicalMemory); //Assert Assert.NotNull(result); Assert.True(double.IsNaN(result.Capacity)); Assert.True(result.FormFactor == "Other"); Assert.False(result.Deleted); Assert.True(result.ID == 0); Assert.True(result.SetID == new Guid(new string('0', 32))); Assert.True(result.Vendor == win32PhysicalMemory.Manufacturer); Assert.True(result.Clocking == 2000); }
public void From_ParameterIsValid_ReturnsDDR(ushort formFactor, string decoded) { //Arrange var win32PhysicalMemory = new Win32_PhysicalMemory { Capacity = 8589934592, ConfiguredClockSpeed = 2000, FormFactor = formFactor, Manufacturer = "Manufacturer" }; //Act var result = DDRMapper.From(win32PhysicalMemory); //Assert Assert.NotNull(result); Assert.True(result.Capacity == 8); Assert.True(result.FormFactor == decoded); Assert.False(result.Deleted); Assert.True(result.ID == 0); Assert.True(result.SetID == new Guid(new string('0', 32))); Assert.True(result.Vendor == win32PhysicalMemory.Manufacturer); Assert.True(result.Clocking == 2000); }
public void From_ManufacturerIsEmpty_ReturnsDDR() { //Arrange var win32PhysicalMemory = new Win32_PhysicalMemory { Capacity = 8589934592, ConfiguredClockSpeed = 2000, FormFactor = 1, Manufacturer = string.Empty }; //Act var result = DDRMapper.From(win32PhysicalMemory); //Assert Assert.NotNull(result); Assert.True(result.Capacity == 8); Assert.True(result.FormFactor == "Other"); Assert.False(result.Deleted); Assert.True(result.ID == 0); Assert.True(result.SetID == new Guid(new string('0', 32))); Assert.True(result.Vendor == "Unknown manufacturer"); Assert.True(result.Clocking == 2000); }
public void From_ConfiguredClockSpeedIsNull_ReturnsDDR() { //Arrange var win32PhysicalMemory = new Win32_PhysicalMemory { Capacity = 8589934592, ConfiguredClockSpeed = null, FormFactor = 1, Manufacturer = "Manufacturer" }; //Act var result = DDRMapper.From(win32PhysicalMemory); //Assert Assert.NotNull(result); Assert.True(result.Capacity == 8); Assert.True(result.FormFactor == "Other"); Assert.False(result.Deleted); Assert.True(result.ID == 0); Assert.True(result.SetID == new Guid(new string('0', 32))); Assert.True(result.Vendor == win32PhysicalMemory.Manufacturer); Assert.True(result.Clocking == Constants.DefaultNumericValue); }