Beispiel #1
0
 public IActionResult Create([FromBody] TypePlan type)
 {
     if (ModelState.IsValid)
     {
         var result     = typeRepository.Create(type);
         var lastResult = result ? typeRepository.GetLastInserted() : null;
         var uri        = Url.Action("Get", new { id = lastResult.Id });
         return(Created(uri, lastResult));
     }
     return(BadRequest());
 }
        public void Create()
        {
            //Arrange
            Type item = new Type()
            {
                Description = "test",
                Status      = "test"
            };

            //Act
            repository.Create(item);
            context.SaveChanges();
            var result = repository.GetAll().ToList();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IEnumerable <Type>));
            Assert.AreEqual(4, result.Count);
            Assert.AreEqual(4, result.Last().ID);
            Assert.AreEqual(item, result.Last());
        }