예제 #1
0
            public async Task TestData(TestDataArguments arguments)
            {
                var(app, service) = Configuration.Setup();

                var taskForSchema    = service.CreateSchemasClient().GetSchemaAsync(app, arguments.Schema);
                var taskForLanguages = service.CreateAppsClient().GetLanguagesAsync(app);

                await Task.WhenAll(
                    taskForSchema,
                    taskForLanguages);

                var datas = new List <DummyData>();

                if (arguments.Count > 0)
                {
                    var generator = new TestDataGenerator(taskForSchema.Result, taskForLanguages.Result);

                    for (var i = 0; i < arguments.Count; i++)
                    {
                        datas.Add(generator.GenerateTestData());
                    }
                }

                if (!string.IsNullOrWhiteSpace(arguments.File))
                {
                    File.AppendAllText(arguments.File, datas.JsonPrettyString());
                }
                else
                {
                    await ImportAsync(arguments, service, datas);
                }
            }
예제 #2
0
            public async Task TestData(TestDataArguments arguments)
            {
                var session = configuration.StartSession();

                var taskForSchema    = session.Schemas.GetSchemaAsync(session.App, arguments.Schema);
                var taskForLanguages = session.Apps.GetLanguagesAsync(session.App);

                await Task.WhenAll(
                    taskForSchema,
                    taskForLanguages);

                var datas = new List <DynamicData>();

                if (arguments.Count > 0)
                {
                    var generator = new TestDataGenerator(taskForSchema.Result, taskForLanguages.Result);

                    for (var i = 0; i < arguments.Count; i++)
                    {
                        datas.Add(generator.GenerateTestData());
                    }
                }

                if (!string.IsNullOrWhiteSpace(arguments.File))
                {
                    await using (var stream = new FileStream(arguments.File, FileMode.Create, FileAccess.Write))
                    {
                        await stream.WriteJsonAsync(datas);
                    }
                }
                else
                {
                    await session.ImportAsync(arguments, log, datas);
                }
            }