Ejemplo n.º 1
0
        public void XmlImport_ExpectOk()
        {
            importer = "Xml";
            Parameter firstParameter = new Parameter();

            firstParameter.Name  = "Path";
            firstParameter.Value = Directory.GetCurrentDirectory() + "\\xmlFile.xml";
            parameters           = new List <Parameter>()
            {
                firstParameter
            };

            importLogic.ImportEverything(importer, parameters);
            var resultArea  = areaLogic.GetByName(area.Name);
            var resultTopic = topicLogic.GetByName(topic.Name);
            var resultType  = typeLogic.GetByName(type.Name);

            areaRepository.VerifyAll();
            topicRepository.VerifyAll();
            typeRepository.VerifyAll();

            Assert.IsNotNull(resultArea);
            Assert.IsNotNull(resultTopic);
            Assert.IsNotNull(resultType);
            Assert.AreEqual(area.Name, resultArea.Name);
            Assert.AreEqual(area.Id, resultArea.Id);
            Assert.AreEqual(topic.Name, resultTopic.Name);
            Assert.AreEqual(topic.Id, resultTopic.Id);
            Assert.AreEqual(topic.AreaEntityId, resultTopic.AreaEntityId);
            Assert.AreEqual(type.Id, resultType.Id);
            Assert.AreEqual(type.Name, resultType.Name);
            Assert.AreEqual(type.TopicEntityId, resultType.TopicEntityId);
        }
Ejemplo n.º 2
0
        public void GetByNameTestOk()
        {
            typeReqRepository.Setup(u => u.Exists(It.IsAny <Expression <Func <TypeReqEntity, bool> > >())).Returns(true);
            typeReqRepository.Setup(r => r.FirstOrDefault(It.IsAny <Expression <Func <TypeReqEntity, bool> > >())).Returns(testTypeReqEntity);

            var result = typeReqLogic.GetByName(testTypeReqEntity.Name);

            typeReqRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(testTypeReqEntity.Name, result.Name);
        }
Ejemplo n.º 3
0
 public IActionResult Post([FromBody] TypeReqModelIn typeReqIn)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var type         = mapper.Map <TypeReqModelIn, TypeReqEntity>(typeReqIn);
             var id           = typeReqLogic.Add(type);
             var addedType    = typeReqLogic.GetByName(type.Name);
             var addedTypeOut = mapper.Map <TypeReqEntity, TypeReqModelOut>(addedType);
             return(Created("Posted succesfully", addedTypeOut));
         }
         catch (ArgumentException ex)
         {
             return(BadRequest(ex.Message));
         }
         catch (Exception ex)
         {
             return(BadRequest(ex.Message));
         }
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }