public async Task CorrectlySeedLocaleCachesOfSampleQueriesWhenMultipleRequestsReceived()
        {
            // Arrange
            _samplesStore = new SamplesStore(_fileUtility, _configuration, _samplesCache);

            /* Act */

            // Fetch en-US sample queries
            SampleQueriesList englishSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("en-US");

            // Fetch es-ES sample queries
            SampleQueriesList espanolSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("es-ES");

            // Fetch fr-FR sample queries
            SampleQueriesList frenchSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("fr-FR");

            /* Assert */

            // en-US
            Assert.Equal(151, englishSampleQueriesList.SampleQueries.Count);
            Assert.Equal("Getting Started", englishSampleQueriesList.SampleQueries[0].Category);
            Assert.Equal("my profile", englishSampleQueriesList.SampleQueries[0].HumanName);

            // es-ES
            Assert.Equal(149, espanolSampleQueriesList.SampleQueries.Count);
            Assert.Equal("Introducción", espanolSampleQueriesList.SampleQueries[0].Category);
            Assert.Equal("mi perfil", espanolSampleQueriesList.SampleQueries[0].HumanName);

            // fr-FR
            Assert.Equal(149, frenchSampleQueriesList.SampleQueries.Count);
            Assert.Equal("Requêtes de base", frenchSampleQueriesList.SampleQueries[0].Category);
            Assert.Equal("mon profil", frenchSampleQueriesList.SampleQueries[0].HumanName);
        }
        public async Task FetchSamplesFromGithub()
        {
            //Arrange
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile(".\\GithubTestFiles\\appsettings-test.json")
                                .Build();

            string org        = configuration["BlobStorage:Org"];
            string branchName = configuration["BlobStorage:Branch"];

            _samplesStore = new SamplesStore(configuration, _httpClientUtility, _fileUtility, _samplesCache);

            /* Act */

            // Fetch en-US sample queries
            SampleQueriesList englishSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("en-US", org, branchName);

            // Fetch es-ES sample queries
            SampleQueriesList espanolSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("es-ES", org, branchName);

            /* Assert */

            // en-US
            Assert.NotNull(englishSampleQueriesList);
            Assert.Equal(151, englishSampleQueriesList.SampleQueries.Count);

            // es-ES
            Assert.NotNull(espanolSampleQueriesList);
            Assert.Equal(149, espanolSampleQueriesList.SampleQueries.Count);
        }
        public async Task ReturnNullIfSampleQueryFileIsEmpty()
        {
            // Arrange
            _samplesStore = new SamplesStore(_fileUtility, _configuration, _samplesCache);

            // Act - Fetch ja-JP sample queries which is empty
            SampleQueriesList japaneseSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("ja-JP");

            // Assert
            Assert.Null(japaneseSampleQueriesList);
        }
        public async Task ReturnNotNullIfSampleQueriesFileHasEmptyJsonObject()
        {
            //Arrange
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile(".\\GithubTestFiles\\appsettings-test.json")
                                .Build();

            string org        = configuration["BlobStorage:Org"];
            string branchName = configuration["BlobStorage:Branch"];

            _samplesStore = new SamplesStore(configuration, _httpClientUtility, _fileUtility, _samplesCache);

            // Act - Fetch ja-JP sample queries which is empty
            SampleQueriesList japaneseSampleQueriesList = await _samplesStore.FetchSampleQueriesListAsync("ja-JP", org, branchName);

            // Assert
            Assert.NotNull(japaneseSampleQueriesList);
        }
Exemplo n.º 5
0
 public GraphExplorerSamplesController(ISamplesStore samplesStore)
 {
     _samplesStore = samplesStore;
 }