public async Task GetLåneTyper() { using var context = new BankContext(true, ContextOptions); LaaneTypeController controller = new LaaneTypeController(context); var type = await controller.GetLåneTyper(); Assert.IsInstanceOfType(type.Result, typeof(OkObjectResult)); }
public async Task PostLåneType() { using var context = new BankContext(true, ContextOptions); LaaneTypeController controller = new LaaneTypeController(context); //Legger til en ny type var leggTil = await controller.PostLåneType(new LaaneType { Id = 4, Navn = "TestPost", Rente = 10.5m }); Assert.IsInstanceOfType(leggTil.Result, typeof(OkResult)); var antallf = await controller.GetLåneTyper(); Assert.IsInstanceOfType(antallf.Result, typeof(OkObjectResult)); int antall = ((IEnumerable <LaaneType>)((ObjectResult)antallf.Result).Value).Count(); Assert.IsTrue(antall == 4); //fjerner typen var fjernet = await controller.DeleteLåneType(4); Assert.IsInstanceOfType(fjernet, typeof(OkResult)); var antalle = await controller.GetLåneTyper(); Assert.IsInstanceOfType(antalle.Result, typeof(OkObjectResult)); antall = ((IEnumerable <LaaneType>)((ObjectResult)antalle.Result).Value).Count(); Assert.IsTrue(antall == 3); }