Exemple #1
0
        public void DtoToModelEntityTest()
        {
            var componentTypeDto = new ComponentTypeDto
            {
                Id   = 1,
                Name = "CPU"
            };

            var brandDto = new BrandDto
            {
                Id   = 1,
                Name = "Intel"
            };

            var componentDto = new ComponentDto
            {
                Id            = 1,
                Name          = "Intel 6600k",
                ComponentType = componentTypeDto,
                Brand         = brandDto,
                Price         = 100
            };

            var model = _componentMapper.ToEntityModel(componentDto);

            Assert.Equal(componentDto.Id, model.Id);
            Assert.Equal(componentDto.Name, model.Name);
            Assert.Equal(componentDto.Price, model.Price);
            Assert.Equal(componentDto.Brand.Id, model.Brand.Id);
            Assert.Equal(componentDto.Brand.Name, model.Brand.Name);
            Assert.Equal(componentDto.ComponentType.Id, model.ComponentType.Id);
            Assert.Equal(componentDto.ComponentType.Name, model.ComponentType.Name);
        }