Exemple #1
0
        public void ModelEntityToDtoTest()
        {
            var componentTypeModel = new ComponentType
            {
                Id   = 1,
                Name = "CPU"
            };

            var brandModel = new Brand
            {
                Id   = 1,
                Name = "Intel"
            };

            var componentModel = new Component
            {
                Id            = 1,
                Name          = "Intel 6600k",
                ComponentType = componentTypeModel,
                Brand         = brandModel,
                Price         = 100
            };

            var dto = _componentMapper.ToDto(componentModel);

            Assert.Equal(componentModel.Id, dto.Id);
            Assert.Equal(componentModel.Name, dto.Name);
            Assert.Equal(componentModel.Price, dto.Price);
            Assert.Equal(componentModel.Brand.Id, dto.Brand.Id);
            Assert.Equal(componentModel.Brand.Name, dto.Brand.Name);
            Assert.Equal(componentModel.ComponentType.Id, dto.ComponentType.Id);
            Assert.Equal(componentModel.ComponentType.Name, dto.ComponentType.Name);
        }