public async Task GetIncidents() { var mockService = new Mock <IIncidentService>(); mockService.Setup(service => service.GetAll(null)).Returns(GetTestIncidents()); var controller = new IncidentsController(mockService.Object); var result = controller.Get(); Assert.Equal(2, result.Count); }
public async Task ArchiveIncident() { var mockService = new Mock <IIncidentService>(); mockService.Setup(service => service.GetAll(null)).Returns(GetTestIncidents()); var controller = new IncidentsController(mockService.Object); var result = controller.Archive("322323"); var incidents = controller.Get(); Assert.Single(incidents); }
public async Task PostIncident() { var mockService = new Mock <IIncidentService>(); mockService.Setup(service => service.GetAll(null)).Returns(GetTestIncidents()); var controller = new IncidentsController(mockService.Object); var result = controller.Post(new Incident() { _id = Guid.NewGuid().ToString(), isArchived = false, locationId = "23TplPdS", happenedAt = DateTime.Now.AddDays(3), kind = Kinds.ROBBERY }); var incidents = controller.Get(); Assert.Equal(3, incidents.Count); }