public async Task EPSLogControllerTest_Success() { IOptions <Settings> appSettings = Substitute.For <IOptions <Settings> >(); MockEPSLogRepository fakeRepo = new MockEPSLogRepository(); IDistributedCache _cache = FakeCache(); IEPSLogApi epslogAPI = new EPSLogApi(appSettings, fakeRepo); EPSLogController controller = FakeController(_cache, epslogAPI); var epslogs = await controller.Get("07/05/2017", "07/05/2017", null, null); var actualResult = ((Microsoft.AspNetCore.Mvc.ObjectResult)epslogs).Value; var expected = JsonConvert.SerializeObject(fakeRepo.epslogs); var actual = JsonConvert.SerializeObject(actualResult); Assert.Equal(expected, actual); }
public async Task EPSLogControllerTest_FailDaterange() { IOptions <Settings> appSettings = Substitute.For <IOptions <Settings> >(); MockEPSLogRepository fakeRepo = new MockEPSLogRepository(); IDistributedCache _cache = FakeCache(); IEPSLogApi epslogAPI = new EPSLogApi(appSettings, fakeRepo); var localizer = new MockStringLocalizer <EPSLogController>(); localizer[0] = new LocalizedString("EPSLogDateRangeError", "Date range should not be greater than 62 days"); EPSLogController controller = FakeController(_cache, epslogAPI, localizer); var epslogs = await controller.Get("2017-04-01", "2017-07-01", null, null); var actualResult = ((Microsoft.AspNetCore.Mvc.ObjectResult)epslogs); Assert.Equal(actualResult.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); Assert.Equal(actualResult.Value, "Date range should not be greater than 62 days"); }