Exemple #1
0
        public void Mutation_Add_User_With_Child()
        {
            var filePath = UTHelpers.Up();

            var ds = new DataStore(filePath);

            var muation = @"
                    mutation {
                          addUsers ( input: {
                            users: {
                              name: Newton
                              age: 45
                              work: {
                                name: ACME
                              }
                            }
                          }) {
                            users {
                              id
                              name
                              age
                              work {
                                name
                              }
                            }
                          }
                    }";

            var results = GraphQL.GraphQL.HandleQuery(muation, ds);

            var id   = ((dynamic)results.Data["users"]).id;
            var item = ds.GetCollection("users").AsQueryable().First(e => e.id == id);

            Assert.Equal("Newton", item.name);
            Assert.Equal(45, item.age);
            Assert.Equal("ACME", item.work.name);

            UTHelpers.Down(filePath);
        }
Exemple #2
0
        public async Task PutItem_Upsert_Id_String()
        {
            var filePath    = UTHelpers.Up();
            var ds          = new DataStore(filePath);
            var apiSettings = Options.Create(new ApiSettings {
                UpsertOnPut = true
            });

            var controller = new DynamicController(ds, apiSettings);

            var result = await controller.ReplaceItem("my_test_string", "acdc", JToken.Parse("{ 'id': 2, 'text': 'Hello' }")) as NoContentResult;

            Assert.Equal(204, result.StatusCode);

            var itemResult = controller.GetItem("my_test_string", "acdc") as OkObjectResult;

            dynamic item = itemResult.Value as ExpandoObject;

            Assert.Equal("acdc", item.id);
            Assert.Equal("Hello", item.text);

            UTHelpers.Down(filePath);
        }
Exemple #3
0
 public void Dispose()
 {
     TestServer.Stop();
     UTHelpers.Down(_newFilePath);
 }
 public void Stop()
 {
     TestServer.Stop();
     _serverTask = null;
     UTHelpers.Down(_newFilePath);
 }