Ejemplo n.º 1
0
        public async Task Test1()
        {
            var optionsBuilder = new DbContextOptionsBuilder <MeowtownContext>();

            optionsBuilder.UseInMemoryDatabase("Cats");
            var dbContext  = new MeowtownContext(optionsBuilder.Options);
            var controller = new CatsController(dbContext);

            var cat = new CatInputModel()
            {
                Name = "Piet"
            };

            var result = await controller.PostCat(cat);

            var createdAtActionResult = result.Result as CreatedAtActionResult;
            var resultCat             = createdAtActionResult.Value as Cat;

            Assert.AreEqual(cat.Name, resultCat.Name);
        }
Ejemplo n.º 2
0
 public CatsController(MeowtownContext context)
 {
     _context = context;
 }