public void From_ParameterIsNull() { //Arrange Win32_ComputerSystem win32ComputerSystem = null; //Act //Assert Assert.Throws <NullReferenceException>(() => ComputerMapper.From(win32ComputerSystem)); }
public static Computer From(Win32_ComputerSystem win32ComputerSystem) { var output = new Computer(); var manufacturer = !string.IsNullOrWhiteSpace(win32ComputerSystem.Manufacturer) ? win32ComputerSystem.Manufacturer : "Unknown manufacturer"; var model = !string.IsNullOrWhiteSpace(win32ComputerSystem.Model) ? win32ComputerSystem.Model : "Unknown model"; output.Name = $"{manufacturer} - {model}"; return(output); }
public void Dispose() { _service = null; _mockComputerRepo = null; _mockComponentRepo = null; _win32ComputerSystem = null; _win32ComputerSystems = null; _computer1 = null; _computer2 = null; _computer3 = null; _computers = null; _includes = null; GC.SuppressFinalize(this); }
public void From_ModelIsWhitespace_ReturnsComputer() { //Arrange var win32ComputerSystem = new Win32_ComputerSystem { Manufacturer = "Manufacturer", Model = " " }; //Act var result = ComputerMapper.From(win32ComputerSystem); //Assert Assert.NotNull(result); Assert.True(result.ID == 0); Assert.False(result.Deleted); Assert.True(result.Name == "Manufacturer - Unknown model"); }
public void From_ManufacturerIsEmpty_ReturnsComputer() { //Arrange var win32ComputerSystem = new Win32_ComputerSystem { Manufacturer = string.Empty, Model = "Model" }; //Act var result = ComputerMapper.From(win32ComputerSystem); //Assert Assert.NotNull(result); Assert.True(result.ID == 0); Assert.False(result.Deleted); Assert.True(result.Name == "Unknown manufacturer - Model"); }
public void From_ParameterIsValid_ReturnsComputer() { //Arrange var win32ComputerSystem = new Win32_ComputerSystem { Manufacturer = "Manufacturer", Model = "Model" }; //Act var result = ComputerMapper.From(win32ComputerSystem); //Assert Assert.NotNull(result); Assert.True(result.ID == 0); Assert.False(result.Deleted); Assert.True(result.Name == "Manufacturer - Model"); }
private void SetupData() { _win32ComputerSystem = new Win32_ComputerSystem { Model = "Model", Manufacturer = "Manufacturer" }; _win32ComputerSystems = new List <Win32_ComputerSystem> { _win32ComputerSystem }; _computer1 = new Computer { ID = 1, Deleted = false, Name = "Model1 - Manufacturer1" }; _computer2 = new Computer { ID = 2, Deleted = true, Name = "Model2 - Manufacturer2" }; _computer3 = new Computer { ID = 3, Deleted = false, Name = "Model3 - Manufacturer3" }; _computers = new List <Computer> { _computer1, _computer2, _computer3 }; _includes = new List <string>(); _win32ComputerSystemException = false; _batteryException = false; }