Exemple #1
0
        public void From_ParameterIsNull()
        {
            //Arrange
            Win32_ComputerSystem win32ComputerSystem = null;

            //Act
            //Assert
            Assert.Throws <NullReferenceException>(() => ComputerMapper.From(win32ComputerSystem));
        }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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");
        }
Exemple #4
0
        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");
        }
Exemple #5
0
        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();
 }