Esempio n. 1
0
        public async Task GetAppTextNb_StorageReturnsError()
        {
            // Arrange
            memoryCache.Remove("org-app-nb");

            HttpResponseMessage httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.InternalServerError
            };

            InitializeMocks(httpResponseMessage, "texts");
            HttpClient httpClient = new HttpClient(handlerMock.Object);
            TextAppSI  target     = new TextAppSI(appSettingsOptions.Object, platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, memoryCache);

            // Act
            TextResource actual = await target.GetText("org", "app", "nb");

            // Assert
            Assert.Null(actual);
        }
Esempio n. 2
0
        public async Task GetAppTextNb_TextSuccessfullyRetrievedFromCache()
        {
            // Arrange
            memoryCache.Remove("org-app-nb");
            TextResource texts = new TextResource {
                Language = "nb"
            };

            memoryCache.Set("org-app-nb", texts);

            InitializeMocks(new HttpResponseMessage(), "texts");

            HttpClient httpClient = new HttpClient(handlerMock.Object);
            TextAppSI  target     = new TextAppSI(appSettingsOptions.Object, platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, memoryCache);

            // Act
            TextResource actual = await target.GetText("org", "app", "nb");

            // Assert
            Assert.Equal(texts.Language, actual.Language);
        }
Esempio n. 3
0
        public async Task GetAppTextNb_SuccessfulCallToStorage()
        {
            // Arrange
            memoryCache.Remove("org-app-nb");
            TextResource texts = new TextResource {
                Language = "nb"
            };

            HttpResponseMessage httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(texts), Encoding.UTF8, "application/json"),
            };

            InitializeMocks(httpResponseMessage, "texts");
            HttpClient httpClient = new HttpClient(handlerMock.Object);
            TextAppSI  target     = new TextAppSI(appSettingsOptions.Object, platformSettingsOptions.Object, logger.Object, contextAccessor.Object, httpClient, memoryCache);

            // Act
            await target.GetText("org", "app", "nb");

            // Assert
            handlerMock.VerifyAll();
        }