コード例 #1
0
        public void From_ParameterIsNull()
        {
            //Arrange
            Win32_ComputerSystem win32ComputerSystem = null;

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