示例#1
0
        public async Task RetrieveEPSMappingAsync_Success()
        {
            int id = 3;
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi       epsMappingApi      = new EPSMappingApi(appSettings, bApi);
            EPSMappingController controller         = FakeController(_cache, epsMappingApi);

            //.. Act
            var dinfo = await controller.Get(id);

            var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo).Value;

            //..Assert
            Assert.Equal((List <EPSMapping>)(actualRecord), bApi.epsMapping.Where(s => s.versionID == 3).ToList());
        }
示例#2
0
        public async Task RetrieveEPSMappingAsync_Fail()
        {
            MockEPSMappingApiRepository bApi        = new MockEPSMappingApiRepository();
            IDistributedCache           _cache      = FakeCache();
            IOptions <Settings>         appSettings = Substitute.For <IOptions <Settings> >();
            IEPSMappingApi epsMappingApi            = new EPSMappingApi(appSettings, bApi);
            var            localizer = new MockStringLocalizer <EPSMappingController>();

            localizer[0] = new LocalizedString("EPSMappingRetrieveErrorMsg", "Version id is not provided");
            EPSMappingController controller = FakeController(_cache, epsMappingApi, localizer);

            //.. Act
            var dinfo = await controller.Get(0);

            var actualRecord = ((Microsoft.AspNetCore.Mvc.ObjectResult)dinfo);

            //..Assert
            Assert.Equal((actualRecord).StatusCode, 500);
            Assert.Equal(actualRecord.Value, "Version id is not provided");
        }