Пример #1
0
        public async Task DashboardInfoControllerTerminalDetailsTest_GetAnException()
        {
            // Arrange
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();
            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();

            IDistributedCache mockCache = Substitute.For <IDistributedCache>();
            IStringLocalizer <DashboardInfoController> localizer
                = Substitute.For <IStringLocalizer <DashboardInfoController> >();
            string key             = "GenericError";
            string value           = "Error occured";
            var    localizedString = new LocalizedString(key, value);

            localizer[Arg.Any <string>()].ReturnsForAnyArgs(localizedString);
            IOperation          fakeOperation = FakeOperation(_cache);
            IOptions <Settings> appSettings   = Substitute.For <IOptions <Settings> >();
            ILoggingFacade      fakeLogger    = FakeLogger();
            IDashboardInfoApi   dAPI          = new DashboardInfoApi(appSettings, mockRepo);

            dAPI.GetTerminalDetails(0).ThrowsForAnyArgs(new System.Exception());
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);


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

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

            // Assert
            Assert.Equal(actualRecord.StatusCode, 500);
            Assert.Equal(actualRecord.Value, "Error occured");
        }
Пример #2
0
        public async Task DashboardInfoControllerTest_TerminalDetailsAccountSuccess()
        {
            // Arrange
            int lid = 588799;
            MockDashboardInfoRepository repository = new MockDashboardInfoRepository();
            var expectedResult = repository.GetMockTerminalDetails();

            IDashboardInfoRepository mockRepo = FakeRepository();
            IDistributedCache        _cache   = FakeCache();
            IOperation        fakeOperation   = FakeOperation(_cache);
            ILoggingFacade    fakeLogger      = FakeLogger();
            IDashboardInfoApi dAPI            = Substitute.For <IDashboardInfoApi>();

            dAPI.GetTerminalDetails(lid).ReturnsForAnyArgs(expectedResult);
            DashboardInfoController controller = FakeController(dAPI, mockRepo, _cache, fakeOperation, fakeLogger);

            // Act
            var dinfo = await controller.GetTerminalDetails(lid);

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

            // Assert
            Assert.Equal(((Wp.CIS.LynkSystems.Model.TerminalDetails)actualRecord), expectedResult.Result);
        }