Пример #1
0
        /// <summary>
        /// Test a user scenario. Create application, multiple get/put changed data,
        /// </summary>
        /// [Fact]
        public async void TestUserScenario()
        {
            InstanceClient storage         = new InstanceClient(new HttpClient());
            int            instanceOwnerId = 42;

            // Create application instance
            string instanceId = await storage.PostInstances("TEST-sailor", instanceOwnerId);

            Instance instance = await storage.GetInstances(instanceId, instanceOwnerId);

            Dictionary <string, string> data = new Dictionary <string, string>
            {
                { "dataFor", instanceOwnerId.ToString() }
            };

            await storage.PostDataReadFromFile(instanceId, instanceOwnerId, "test.json", "application/json");

            Instance instanceUpdated = await storage.GetInstances(instanceId, instanceOwnerId);

            string dataId = instance.Data.Find(m => m.FormId.Equals("default")).Id;

            for (int i = 0; i < 100; i++)
            {
                data.Add("field" + i, RandomString(i));

                logger.Information(data["field" + i]);

                /*
                 * storage.PutData(instanceId, dataId, instanceOwnerId, "test.json", "applicatino/json", data);
                 *
                 * var storedData = storage.GetData(instanceId, dataId, instanceOwnerId);
                 */
            }
        }
        public async void StoreAForm()
        {
            object jsonContent = new
            {
                universe = 42,
                årsjul   = 365,
                text     = "Fem flotte åer er bedre en to ærlige øl!",
            };

            // create instance
            string newId = await storageClient.PostInstances(testApplicationId, testInstanceOwnerId);

            Instance instance = await storageClient.GetInstances(newId, testInstanceOwnerId);

            string requestUri = $"{versionPrefix}/instances/{newId}/data?formId={formId}&instanceOwnerId={testInstanceOwnerId}";

            // post the file
            HttpResponseMessage postResponse = await client.PostAsync(requestUri, jsonContent.AsJson());

            postResponse.EnsureSuccessStatusCode();
        }