コード例 #1
0
        public async void AddTemplateReturnTest()
        {
            //Given
            var con = new ItemTemplateController(_repo, _dbContext, _mapper, _userManager, _eventLogRepo);

            var listTP = new List <TemplatePropertyRelation>();

            listTP.AddRange(_dbContext.TemplatePropertyRelations.Where(x => x.TemplateId == 1));
            listTP.AddRange(_dbContext.TemplatePropertyRelations.Where(x => x.TemplateId == 2));

            var template = new ItemTemplate(
                "Dør",
                new UnitType
            {
                Name = "test"
            },
                "Dette er en Dør",
                listTP,
                new List <ItemTemplatePart>()
            {
            },
                new List <ItemTemplatePart>()
            {
            },
                new DateTime {
            },
                new ItemTemplate {
            },
                new List <TemplateFileName>(),
                0,
                new ItemTemplateCategory {
            }
                );
            //When
            var status = await con.AddItemTemplate(_mapper.Map <ItemTemplateForAddDto>(template));

            StatusCodeResult result = status as StatusCodeResult;
            var test = new StatusCodeResult(201);

            Assert.True(result.StatusCode == test.StatusCode);
        }
コード例 #2
0
        public async void AddTemplateTest()
        {
            //Given
            var listTP = new List <TemplatePropertyRelation>();

            listTP.AddRange(_dbContext.TemplatePropertyRelations.Where(x => x.TemplateId == 1));
            listTP.AddRange(_dbContext.TemplatePropertyRelations.Where(x => x.TemplateId == 2));


            var con      = new ItemTemplateController(_repo, _dbContext, _mapper, _userManager, _eventLogRepo);
            var template = new ItemTemplate(
                "Dør",
                new UnitType
            {
                Name = "test"
            },
                "Dette er en Dør",
                listTP,
                new List <ItemTemplatePart>()
            {
            },
                new List <ItemTemplatePart>()
            {
            },
                new DateTime {
            },
                new ItemTemplate {
            },
                new List <TemplateFileName>(),
                0,
                new ItemTemplateCategory {
            }
                );
            //When
            await con.AddItemTemplate(_mapper.Map <ItemTemplateForAddDto>(template));

            var dbTemplate = _dbContext.ItemTemplates.FirstOrDefault(x => x.Name == "Dør");

            //Then
            Assert.True(dbTemplate.Name == template.Name);
        }