Exemplo n.º 1
0
    public async Task Where_case_sensitive()
    {
        var query = @"
{
  parentEntities (where: {path: 'Property', comparison: 'equal', value: 'Value2', case: 'Ordinal' })
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 2
0
    public async Task Connection_nested()
    {
        var query    = @"
{
  parentEntities {
    id
    childrenConnection(first:2, after:""2"") {
      edges {
        cursor
        node {
          id
        }
      }
	  pageInfo {
		  endCursor
		  hasNextPage
		}
    }
  }
}
";
        var entities = BuildEntities(8);

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, entities.ToArray());

        ObjectApprover.Verify(result);
    }
Exemplo n.º 3
0
    public async Task Like()
    {
        var query = @"
{
  parentEntities (where: {path: 'Property', comparison: 'Like', value: 'value2'})
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, entity1, entity2);

        ObjectApprover.Verify(result);
    }
Exemplo n.º 4
0
    public async Task Multiple_nested()
    {
        var query = @"
{
  level1Entities
  {
    level2Entity
    {
      level3Entity
      {
        property
      }
    }
  }
}";

        var level3 = new Level3Entity
        {
            Property = "Value"
        };
        var level2 = new Level2Entity
        {
            Level3Entity = level3
        };
        var level1 = new Level1Entity
        {
            Level2Entity = level2
        };

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, level1, level2, level3);

        ObjectApprover.Verify(result);
    }
Exemplo n.º 5
0
    public async Task Skip()
    {
        var query = @"
{
  parentEntities (skip: 1)
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, entity1, entity2);

        ObjectApprover.Verify(result);
    }
    public void GetNextChunk()
    {
        var startSlice   = new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc);
        var timeout1Time = startSlice.AddSeconds(1);
        var timeout2Time = DateTime.UtcNow.AddSeconds(10);
        var timeout1     = new TimeoutData
        {
            Destination = "theDestination",
            State       = new byte[] { 1 },
            Time        = timeout1Time,
            Headers     = new Dictionary <string, string>()
        };
        var timeout2 = new TimeoutData
        {
            Destination = "theDestination",
            State       = new byte[] { 1 },
            Time        = timeout2Time,
            Headers     = new Dictionary <string, string>()
        };
        var persister = Setup();

        persister.Add(timeout1, null).Await();
        persister.Add(timeout2, null).Await();
        var nextChunk = persister.GetNextChunk(startSlice).Result;

        Assert.That(nextChunk.NextTimeToQuery, Is.EqualTo(timeout2Time).Within(TimeSpan.FromSeconds(1)));
        ObjectApprover.VerifyWithJson(nextChunk.DueTimeouts, s => s.Replace(timeout1.Id, "theId"));
    }
    public async Task RootList_filtered()
    {
        var query = @"
{
  parentEntitiesFiltered
  {
    property
  }
}";

        var entity1 = new FilterParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new FilterParentEntity
        {
            Property = "Ignore"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, BuildFilters(), entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 8
0
    public async Task In_multiple()
    {
        var query = @"
{
  parentEntities
  (where: {path: 'Property', comparison: 'In', value: ['Value1', 'Value2']})
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 9
0
    public void List(int?first, int?after, int?last, int?before)
    {
        NamerFactory.AdditionalInformation = $"first_{first}_after_{after}_last_{last}_before_{before}";
        var connection = ConnectionConverter.ApplyConnectionContext(list, first, after, last, before);

        ObjectApprover.VerifyWithJson(connection);
    }
Exemplo n.º 10
0
    public async Task NamedId()
    {
        var query = @"
{
  namedEntities (ids: '00000000-0000-0000-0000-000000000001')
  {
    property
  }
}";

        var entity1 = new NamedIdEntity
        {
            NamedId  = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new NamedIdEntity
        {
            Property = "Value2"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 11
0
    public async Task Id_multiple()
    {
        var query = @"
{
  parentEntities
  (ids: ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002'])
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000002"),
            Property = "Value2"
        };
        var entity3 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000003"),
            Property = "Value3"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2, entity3);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 12
0
    public async Task Id_string()
    {
        var query = @"
query ($id: String!)
{
  parentEntities(id:$id)
  {
    id
  }
}";

        var entity1 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        var inputs = new Inputs(
            new Dictionary <string, object>
        {
            { "id", "00000000-0000-0000-0000-000000000001" }
        });

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, inputs, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 13
0
    public async Task SingleNullable_Found()
    {
        var query   = @"
{
  parentEntityNullable(id: ""00000000-0000-0000-0000-000000000001"") {
    property
  }
}";
        var entity1 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000002"),
            Property = "Value2"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 14
0
    public async Task CustomType()
    {
        var query = @"
{
  customType
  {
    property
  }
}";

        var entity1 = new CustomTypeEntity
        {
            Property = long.MaxValue
        };
        var entity2 = new CustomTypeEntity
        {
            Property = 3
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, null, entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 15
0
    public void IntegrationTest()
    {
        var testDirectory = TestContext.CurrentContext.TestDirectory;
        var temp          = Path.Combine(testDirectory, "InnerTaskTemp");

        if (!Directory.Exists(temp))
        {
            return;
        }
        Directory.Delete(temp, true);
        var intermediatePath = Path.Combine(temp, "IntermediatePath");

        Directory.CreateDirectory(temp);
        Directory.CreateDirectory(intermediatePath);

        var innerTask = new InnerTask(
            assemblyPath: Path.Combine(testDirectory, "ScriptBuilderTask.Tests.Target.dll"),
            intermediateDirectory: intermediatePath,
            projectDirectory: "TheProjectDir",
            solutionDirectory: Path.Combine(temp, "PromotePath"),
            logError: (error, s1) => throw new Exception(error));

        innerTask.Execute();
        var files = Directory.EnumerateFiles(temp, "*.*", SearchOption.AllDirectories).Select(s => s.Replace(temp, "temp")).ToList();

        Assert.IsNotEmpty(files);

#if NET452
        ObjectApprover.VerifyWithJson(files);
#endif
    }
Exemplo n.º 16
0
    public void RemoveDuplicateNewlines()
    {
        var input    = @"


  <!-- startcode KeyParent -->


  a


  <!-- startcode KeyChild -->


  b


  <!-- endcode -->


  c


  <!-- endcode -->


";
        var snippets = FromText(input);

        ObjectApprover.VerifyWithJson(snippets);
    }
Exemplo n.º 17
0
    public void Pull_branch_with_2_commits()
    {
        var repoPath = Clone(ASBMTestRepoWorkingDirPath);

        using (var repo = new Repository(repoPath))
        {
            // Create a pull request branch from the parent of current develop tip
            repo.Branches.Add("pull/1735/merge", "develop~").ForceCheckout();

            AddOneCommitToHead(repo, "code");
            AddOneCommitToHead(repo, "more code");

            var pullBranch = repo.Head;

            var finder = new PullVersionFinder();

            var version = finder.FindVersion(new GitVersionContext(repo, pullBranch));

            var masterVersion = FindersHelper.RetrieveMasterVersion(repo);

            Assert.AreEqual(masterVersion.Minor + 1, version.Minor, "Minor should be master.Minor+1");
            Assert.AreEqual(1735, version.PreReleaseTag.Number);
            ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
        }
    }
Exemplo n.º 18
0
    public async Task AppendUrlAsSnippet()
    {
        var snippets = new List <Snippet>();
        await snippets.AppendUrlAsSnippet("https://raw.githubusercontent.com/SimonCropp/MarkdownSnippets/master/src/appveyor.yml");

        ObjectApprover.VerifyWithJson(snippets);
    }
    public void ToSerializable()
    {
        var operations = new List <TransportOperation>
        {
            new TransportOperation(
                messageId: "Id1",
                options: new Dictionary <string, string>
            {
                {
                    "OptionKey1", "OptionValue1"
                }
            },
                body: new byte[] { 0x20, 0x21 },
                headers: new Dictionary <string, string>
            {
                {
                    "HeaderKey1", "HeaderValue1"
                }
            }
                )
        };
        var serializableOperations = operations.ToSerializable();

        ObjectApprover.VerifyWithJson(serializableOperations);
    }
Exemplo n.º 20
0
    public void Write_after_dispose_should_throw()
    {
        base.Dispose();
        var exception = Assert.Throws <Exception>(WriteLine);

        ObjectApprover.Verify(exception);
    }
    public async Task Root_connectionFiltered()
    {
        var query   = @"
{
  parentEntitiesConnectionFiltered {
    totalCount
    edges {
      cursor
      node {
        property
      }
    }
    items {
      property
    }
  }
}
";
        var entity1 = new FilterParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new FilterParentEntity
        {
            Property = "Ignore"
        };

        using (var database = await sqlInstance.Build())
        {
            var result = await RunQuery(database, query, null, BuildFilters(), entity1, entity2);

            ObjectApprover.Verify(result);
        }
    }
Exemplo n.º 22
0
 public void Dispose_should_flush()
 {
     Write("part1");
     Write(" part2");
     base.Dispose();
     ObjectApprover.Verify(Logs);
 }
Exemplo n.º 23
0
    public async Task Many_children()
    {
        var query = @"
{
  manyChildren
  {
    child1
    {
      id
    }
  }
}";

        var parent = new WithManyChildrenEntity();
        var child1 = new Child1Entity
        {
            Parent = parent
        };
        var child2 = new Child2Entity
        {
            Parent = parent
        };

        parent.Child1 = child1;
        parent.Child2 = child2;

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, parent, child1, child2);

        ObjectApprover.Verify(result);
    }
    public async Task RootList_filtered()
    {
        var queryString = @"
{
  parentEntitiesFiltered
  {
    property
  }
}";

        var entity1 = new FilterParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new FilterParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000002"),
            Property = "Ignore"
        };

        var result = await RunQuery(queryString, null, entity1, entity2);

        ObjectApprover.VerifyWithJson(result);
    }
Exemplo n.º 25
0
    public async Task Connection_first_page()
    {
        var query    = @"
{
  parentEntitiesConnection(first:2, after: '0') {
    totalCount
    edges {
      cursor
      node {
        property
      }
    }
    items {
      property
    }
  }
}
";
        var entities = BuildEntities(8);

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, entities.ToArray());

        ObjectApprover.Verify(result);
    }
    public async Task Root_connectionFiltered()
    {
        var queryString = @"
{
  parentEntitiesConnectionFiltered {
    totalCount
    edges {
      cursor
      node {
        property
      }
    }
    items {
      property
    }
  }
}
";
        var entity1     = new FilterParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000001"),
            Property = "Value1"
        };
        var entity2 = new FilterParentEntity
        {
            Id       = Guid.Parse("00000000-0000-0000-0000-000000000002"),
            Property = "Ignore"
        };


        var result = await RunQuery(queryString, null, entity1, entity2);

        ObjectApprover.VerifyWithJson(result);
    }
Exemplo n.º 27
0
    public async Task OrderByDescending()
    {
        var query = @"
{
  parentEntities (orderBy: {path: 'Property', descending: true})
  {
    property
  }
}";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, null, null, entity1, entity2);

        ObjectApprover.Verify(result);
    }
Exemplo n.º 28
0
    public virtual void SaveWithWeirdCharacters()
    {
        var endpointName = nameof(SaveWithWeirdCharacters);
        var definition   = new SagaDefinition(
            tableSuffix: "SagaWithWeirdCharactersಠ_ಠ",
            name: "SagaWithWeirdCharactersಠ_ಠ",
            correlationProperty: new CorrelationProperty
            (
                name: "SimplePropertyಠ_ಠ",
                type: CorrelationPropertyType.String
            )
            );

        var execute = new TestDelegate(() =>
        {
            DropAndCreate(definition, endpointName, schema);
            var id     = Guid.NewGuid();
            var result = SaveWeirdAsync(id, endpointName).GetAwaiter().GetResult();
            Assert.IsNotNull(result);
#if net452
            ObjectApprover.VerifyWithJson(result, s => s.Replace(id.ToString(), "theSagaId"));
#endif
        });

        if (SupportsUnicodeIdentifiers)
        {
            execute();
        }
        else
        {
            Assert.Throws <Exception>(execute);
        }
    }
Exemplo n.º 29
0
    public async Task Where_with_variable()
    {
        var query = @"
query ($value: String!)
{
  parentEntities (where: {path: 'Property', comparison: 'equal', value: [$value]})
  {
    property
  }
}
";

        var entity1 = new ParentEntity
        {
            Property = "Value1"
        };
        var entity2 = new ParentEntity
        {
            Property = "Value2"
        };

        var inputs = new Inputs(
            new Dictionary <string, object>
        {
            { "value", "value2" }
        });

        await using var database = await sqlInstance.Build();

        var result = await RunQuery(database, query, inputs, null, entity1, entity2);

        ObjectApprover.Verify(result);
    }
Exemplo n.º 30
0
    public void Feature_branch_with_2_commits_but_building_an_commit()
    {
        var repoPath = Clone(ASBMTestRepoWorkingDirPath);

        using (var repo = new Repository(repoPath))
        {
            // Create a feature branch from the parent of current develop tip
            repo.Branches.Add("featureWithOneCommit", "develop~").ForceCheckout();
            //var branchingCommit = repo.Head.Tip;

            AddOneCommitToHead(repo, "feature");
            AddOneCommitToHead(repo, "feature");

            var featureBranch = repo.Branches["featureWithOneCommit"];

            var finder = new FeatureVersionFinder();

            var version = finder.FindVersion(new GitVersionContext(repo, featureBranch));

            var masterVersion = FindersHelper.RetrieveMasterVersion(repo);

            Assert.AreEqual(masterVersion.Minor + 1, version.Minor, "Minor should be master.Minor+1");
            //TODO Assert.AreEqual(branchingCommit.Prefix(), version.Version.Suffix, "Suffix should be the develop commit it was branched from");
            ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
        }
    }