Пример #1
0
        public static async Task Main(string[] args)
        {
            try
            {
                IConfigurationRoot configuration = new ConfigurationBuilder()
                                                   .AddJsonFile("appSettings.json")
                                                   .Build();

                _accountName = GetConfigValueOrDefault <string>(configuration, "AccountName", true);
                _accountKey  = GetConfigValueOrDefault <string>(configuration, "AccountKey", true);
                _databaseId  = GetConfigValueOrDefault <string>(configuration, "DatabaseId", true);
                _containerId = GetConfigValueOrDefault <string>(configuration, "ContainerId", true);

                _graphClient = await CosmosClientGraph.GetClientWithSql(_accountName, _accountKey, _databaseId, _containerId, new CreateOptions(_databaseId, _containerId));

                Console.Title = "CosmosDB.NET Gremlin Sample";
                await new ConsoleREPL(new Program()).RunLoop();
            }
            catch (CosmosException cre)
            {
                Console.WriteLine(cre.ToString());
            }
            catch (Exception e)
            {
                Exception baseException = e.GetBaseException();
                Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
            }
            finally
            {
                Console.WriteLine("End of demo, press any key to exit.");
                Console.ReadKey();
            }
        }
        public static async Task Initialize(TestContext context)
        {
            var moviesCsv = Helpers.GetFromCsv <MovieCsv>(moviesTestDataPath);
            var castCsv   = Helpers.GetFromCsv <CastCsv>(castTestDataPath);

            _movies = moviesCsv.Select(MovieFullGraph.GetMovieFullGraph).ToList();
            var moviesDic = _movies.ToDictionary(k => k.TmdbId);

            _cast = castCsv.Select(c => Cast.GetCastFromCsv(c)).GroupBy(k => k.MovieId).ToDictionary(k => k.Key, v => v.ToList());

            Assert.AreEqual(4802, moviesCsv.Count());

            _cosmosClient = await CosmosClientGraph.GetClientWithSql(accountName, accountKey, databaseId, containerId);
        }