public void From_ParameterIsNull() { //Arrange Win32_ComputerSystem win32ComputerSystem = null; //Act //Assert Assert.Throws <NullReferenceException>(() => ComputerMapper.From(win32ComputerSystem)); }
public async Task <Result <IEnumerable <Computer> > > GetPhysicalComputersAsync() { try { var result = await Task.Run(() => _componentRepo.Get <Win32_ComputerSystem>()); var output = result.Select(x => ComputerMapper.From(x)).ToList(); return(Result <IEnumerable <Computer> > .Ok(output)); } catch (Exception e) { return(Result <IEnumerable <Computer> > .Fail(e)); } }
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"); }
// GET: api/Computers /// <summary> /// Controller constructor /// </summary> /// <param name="bll"></param> public ComputersController(IAppBLL bll) { _bll = bll; _mapper = new ComputerMapper(); }