Пример #1
0
 public void Complex()
 {
     var context = TestExecuter.GetContext();
     var builder = SequenceBuilder.Fluent
                   .ReadFrom(TestData.Person(context))
                   .ExpandFromLookup(new ExpandFromLookupMutator(context)
     {
         LookupBuilder = new RowLookupBuilder()
         {
             Process      = TestData.Country(context),
             KeyGenerator = row => row.GenerateKey("id"),
         },
         MatchSelector = (row, lookup) =>
         {
             return(lookup.GetSingleRowByKey(row.GenerateKey("countryId")));
         },
         NoMatchAction = new NoMatchAction(MatchMode.Custom)
         {
             CustomAction = row =>
             {
                 row["countryAbbrev"] = !row.HasValue("countryId")
                         ? "country was null"
                         : "no match found";
             }
         },
         MatchCustomAction = (row, match) => row["countryAbbrevFound"] = true,
         Columns           = new()
         {
Пример #2
0
 public void DummyForDevelopment3()
 {
     var context = TestExecuter.GetContext();
     var builder = ProcessBuilder.Fluent
                   .ReadFrom(TestData.Person(context))
                   .Join(new JoinMutator(context)
     {
         LookupBuilder = new RowLookupBuilder()
         {
             Process      = TestData.PersonEyeColor(context),
             KeyGenerator = row => row.GenerateKey("personId"),
         },
         RowKeyGenerator = row => row.GenerateKey("id"),
         NoMatchAction   = new NoMatchAction(MatchMode.Throw),
         Columns         = new(),
     });
Пример #3
0
        public void NullableMulti()
        {
            var topic   = TestExecuter.GetTopic();
            var lookup  = new CountableOnlyRowLookup();
            var builder = new RowLookupBuilder()
            {
                Process      = TestData.Person(topic),
                KeyGenerator = row => row.GenerateKey("name"),
            };

            builder.Append(lookup, null);
            Assert.AreEqual(6, lookup.Keys.Count());
            Assert.AreEqual(2, lookup.CountByKey("A"));
            Assert.AreEqual(1, lookup.CountByKey("B"));
            Assert.AreEqual(1, lookup.CountByKey("C"));
            Assert.AreEqual(1, lookup.CountByKey("D"));
            Assert.AreEqual(1, lookup.CountByKey("E"));
            Assert.AreEqual(1, lookup.CountByKey("fake"));
        }
Пример #4
0
 public void NoMatchCustom()
 {
     var context = TestExecuter.GetContext();
     var builder = ProcessBuilder.Fluent
                   .ReadFrom(TestData.Person(context))
                   .Join(new JoinMutator(context)
     {
         LookupBuilder = new RowLookupBuilder()
         {
             Process      = TestData.PersonEyeColor(context),
             KeyGenerator = row => row.GenerateKey("personId"),
         },
         RowKeyGenerator = row => row.GenerateKey("id"),
         NoMatchAction   = new NoMatchAction(MatchMode.Custom)
         {
             CustomAction = row => row["eyeColor"] = "not found",
         },
         Columns = new()
         {
Пример #5
0
        public void NotNullIdentity()
        {
            var topic   = TestExecuter.GetTopic();
            var lookup  = new CountableOnlyRowLookup();
            var builder = new RowLookupBuilder()
            {
                Process      = TestData.Person(topic),
                KeyGenerator = row => row.GenerateKey("id"),
            };

            builder.Append(lookup, null);
            Assert.AreEqual(7, lookup.Keys.Count());
            Assert.AreEqual(7, lookup.Count);
            Assert.AreEqual(1, lookup.CountByKey("0"));
            Assert.AreEqual(1, lookup.CountByKey("1"));
            Assert.AreEqual(1, lookup.CountByKey("2"));
            Assert.AreEqual(1, lookup.CountByKey("3"));
            Assert.AreEqual(1, lookup.CountByKey("4"));
            Assert.AreEqual(1, lookup.CountByKey("5"));
            Assert.AreEqual(1, lookup.CountByKey("6"));
        }
Пример #6
0
        public void NullableIdentity()
        {
            var topic   = TestExecuter.GetTopic();
            var lookup  = new CountableOnlyRowLookup();
            var builder = new RowLookupBuilder()
            {
                Process      = TestData.Person(topic),
                KeyGenerator = row => row.GenerateKey("age"),
            };

            builder.Append(lookup, null);
            Assert.AreEqual(6, lookup.Keys.Count());
            Assert.AreEqual(6, lookup.Count);
            Assert.AreEqual(1, lookup.CountByKey("17"));
            Assert.AreEqual(1, lookup.CountByKey("8"));
            Assert.AreEqual(1, lookup.CountByKey("27"));
            Assert.AreEqual(1, lookup.CountByKey("39"));
            Assert.AreEqual(1, lookup.CountByKey("-3"));
            Assert.AreEqual(1, lookup.CountByKey("11"));
            Assert.AreEqual(0, lookup.CountByKey(null));
        }