Beispiel #1
0
        public async Task LoadMovies(string parameter = "")
        {
            //Load sample data
            var movies = DataLoader.LoadMovies().Select(m => m.ToMovie());

            //Parse parameters
            var args = Parse2intParameters(parameter, movies.Count());

            //Upsert movies
            var startTime = DateTime.Now;

            ConsoleHelpers.ConsoleLine($"Inserting {args.records} movies (using {args.threads} threads)...");
            var upsertResult = await _graphClient.UpsertVertex(movies.Take(args.records), (res) => { ConsoleHelpers.ConsoleLine($"processed {res.Count()}/{args.records} movies"); }, threads : args.threads);

            ConsoleHelpers.PrintStats(upsertResult, DateTime.Now.Subtract(startTime).TotalSeconds);
        }
        public async Task UpsertVertex()
        {
            var movie = _movies.ElementAt(0);

            var upsert = await _cosmosClient.UpsertVertex(movie);

            Assert.IsTrue(upsert.IsSuccessful);

            var read = await _cosmosClient.ReadVertex <MovieFullGraph>(movie.TmdbId, movie.Title);

            Assert.IsTrue(read.IsSuccessful);

            Helpers.AssertMovieFullIsSame(movie, read.Result);

            movie.Budget += 1;

            var upsert2 = await _cosmosClient.UpsertVertex(movie);

            Assert.IsTrue(upsert2.IsSuccessful);
            var read2 = await _cosmosClient.ReadVertex <MovieFullGraph>(movie.TmdbId, movie.Title);

            Assert.IsTrue(read.IsSuccessful);

            Helpers.AssertMovieFullIsSame(movie, read2.Result);
        }