예제 #1
0
        public async Task EPSPetroAuditControllerTest_SuccessByAuditId()
        {
            int auditID = 2471;
            IOptions <Settings>         appSettings      = Substitute.For <IOptions <Settings> >();
            MockEPSPetroAuditRepository fakeRepo         = new MockEPSPetroAuditRepository();
            IDistributedCache           _cache           = FakeCache();
            IEPSPetroAuditApi           epsPetroAuditAPI = new EPSPetroAuditApi(appSettings, fakeRepo);
            EPSPetroAuditController     controller       = FakeController(_cache, epsPetroAuditAPI);

            var epsPetroAudits = await controller.GetEPSPetroAuditDetails(auditID);

            var actualResult = ((Microsoft.AspNetCore.Mvc.ObjectResult)epsPetroAudits).Value;
            var expected     = JsonConvert.SerializeObject(fakeRepo.epsPetroAuditDetails.Where(s => s.auditId == auditID));
            var actual       = JsonConvert.SerializeObject(actualResult);

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public async Task EPSPetroAuditControllerTest_FailByAuditId()
        {
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            MockEPSPetroAuditRepository fakeRepo    = new MockEPSPetroAuditRepository();
            IDistributedCache           _cache      = FakeCache();
            var localizer = new MockStringLocalizer <EPSPetroAuditController>();

            localizer[0] = new LocalizedString("InValidAuditIdError", "Invalid AuditId");
            IEPSPetroAuditApi       epsPetroAuditAPI = new EPSPetroAuditApi(appSettings, fakeRepo);
            EPSPetroAuditController controller       = FakeController(_cache, epsPetroAuditAPI, localizer);

            var epsPetroAudits = await controller.GetEPSPetroAuditDetails(0);

            var actualResult = ((Microsoft.AspNetCore.Mvc.ObjectResult)epsPetroAudits);

            Assert.Equal(actualResult.StatusCode, (int)System.Net.HttpStatusCode.BadRequest);
            Assert.Equal((actualResult.Value), "Invalid AuditId");
        }