public async Task GetEnvironmentsById() { // arrange var serializer = new IdSerializer(); var environment = new Environment(Guid.NewGuid(), "abc", "def"); await EnvironmentRepository.AddEnvironmentAsync(environment); string id = serializer.Serialize("Environment", environment.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($ids: [ID!]!) { environmentsById(ids: $ids) { id name description } }") .SetVariableValue("ids", new[] { id }) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.Equal(id, fo.Field <string>("Data.environmentsById[0].id")))); }
public async Task UpdateSchema() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string id = serializer.Serialize("Schema", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"mutation($id: ID!) { updateSchema(input: { id: $id name: ""abc2"" description: ""def2"" clientMutationId: ""ghi"" }) { schema { id name description } clientMutationId } }") .SetVariableValue("id", id) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.NotNull(fo.Field <string>("Data.updateSchema.schema.id")))); }
public async Task GetSchemaVersionsById_Invalid_Id_Type() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); var schemaVersion = new SchemaVersion( Guid.NewGuid(), schema.Id, "abc", "def", Array.Empty <Tag>(), DateTime.UnixEpoch); await SchemaRepository.AddSchemaVersionAsync(schemaVersion); string id = serializer.Serialize("Foo", schemaVersion.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($ids: [ID!]!) { schemaVersionsById(ids: $ids) { id sourceText } }") .SetVariableValue("ids", new[] { id }) .Create()); // assert result.MatchSnapshot(); }
public async Task GetSchemaById_Invalid_Id_Type() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string id = serializer.Serialize("Foo", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($id: ID!) { schemaById(id: $id) { id name description } }") .SetVariableValue("id", id) .Create()); // assert result.MatchSnapshot(); }
public async Task QuerySchema() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string id = serializer.Serialize("Schema", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($name: String!) { schemas(where: { name: $name }) { nodes { id name description } } }") .SetVariableValue("name", schema.Name) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.Equal(id, fo.Field <string>("Data.schemas.nodes[0].id")))); }
public async Task GetSchemaVersionById() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); var schemaVersion = new SchemaVersion( Guid.NewGuid(), schema.Id, "abc", "def", Array.Empty <Tag>(), DateTime.UnixEpoch); await SchemaRepository.AddSchemaVersionAsync(schemaVersion); string id = serializer.Serialize("SchemaVersion", schemaVersion.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($id: ID!) { schemaVersionById(id: $id) { id sourceText } }") .SetVariableValue("id", id) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.Equal(id, fo.Field <string>("Data.schemaVersionById.id")))); }
public async Task GetSchemasByNames_Empty_Names() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string id = serializer.Serialize("Schema", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($names: [String!]!) { schemasByName(names: $names) { id name description } }") .SetVariableValue("names", new string[0]) .Create()); // assert result.MatchSnapshot(); }
public async Task GetSchemaAsNode() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string id = serializer.Serialize("Schema", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($id: ID!) { node(id: $id) { id ... on Schema { name description } } }") .SetVariableValue("id", id) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.Equal(id, fo.Field <string>("Data.node.id")))); }
public async Task GetSchemaVersionAsNode() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); var schemaVersion = new SchemaVersion( Guid.NewGuid(), schema.Id, "abc", DocumentHash.FromSourceText("def"), Array.Empty <Tag>(), DateTime.UnixEpoch); await SchemaRepository.AddSchemaVersionAsync(schemaVersion); string id = serializer.Serialize("SchemaVersion", schemaVersion.Id); IFileContainer container = await Storage.CreateContainerAsync( schemaVersion.Id.ToString("N", CultureInfo.InvariantCulture)); byte[] buffer = Encoding.UTF8.GetBytes("SourceTextAbc"); await container.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($id: ID!) { node(id: $id) { id ... on SchemaVersion { sourceText hash { hash } } } }") .SetVariableValue("id", id) .Create()); // assert result.MatchSnapshot(o => o.Assert(fo => Assert.Equal(id, fo.Field <string>("Data.node.id")))); }
public async Task CreateClient() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); string schemaId = serializer.Serialize("Schema", schema.Id); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"mutation($schemaId: ID! $name: String! $description: String) { createClient(input: { schemaId: $schemaId name: $name description: $description }) { schema { name description } client { name description } } }") .SetVariableValue("schemaId", schemaId) .SetVariableValue("name", "client_abc") .SetVariableValue("description", "client_def") .Create()); // assert result.MatchSnapshot(); }
public async Task GetSchemaVersionsById_Invalid_Id_Type() { // arrange var serializer = new IdSerializer(); var schema = new Schema(Guid.NewGuid(), "abc", "def"); await SchemaRepository.AddSchemaAsync(schema); var schemaVersion = new SchemaVersion( Guid.NewGuid(), schema.Id, "abc", DocumentHash.FromSourceText("def"), Array.Empty <Tag>(), DateTime.UnixEpoch); await SchemaRepository.AddSchemaVersionAsync(schemaVersion); string id = serializer.Serialize("Foo", schemaVersion.Id); IFileContainer container = await Storage.CreateContainerAsync( schemaVersion.Id.ToString("N", CultureInfo.InvariantCulture)); byte[] buffer = Encoding.UTF8.GetBytes("SourceTextAbc"); await container.CreateFileAsync("schema.graphql", buffer, 0, buffer.Length); // act IExecutionResult result = await Executor.ExecuteAsync( QueryRequestBuilder.New() .SetQuery( @"query($ids: [ID!]!) { schemaVersionsById(ids: $ids) { id sourceText } }") .SetVariableValue("ids", new[] { id }) .Create()); // assert result.MatchSnapshot(); }