示例#1
0
 public void GetContext(CassandraLogContext cntxt)
 {
     this.context   = cntxt;
     this.LogsTable = cntxt.GetTable <CassandraLog>();
     this.canWrite  = true;
     Update(logsTableLocal);
 }
示例#2
0
 public void GetContext(CassandraLogContext cntxt)
 {
     this.context = cntxt;
     this.LogsTable = cntxt.GetTable<CassandraLog>();
     this.canWrite = true;
     Update(logsTableLocal);
 }
示例#3
0
            public void NoContextAddsFirstSymbolToTable()
            {
                byte symbol = 103;
                var  ct     = new ContextTable();

                ct.UpdateContext(new Entry(symbol, new byte[0]));

                Assert.IsTrue(ct[new byte[0]].ContainsKey(symbol));
            }
示例#4
0
        public ValidationData CreateValidationData()
        {
            ContextTable     table   = CreateContextTable();
            ValidationFlow   flow    = CreateValidationFlow();
            BindingContainer binding = CreateBindingContainer();

            ValidationData data = new ValidationData(table, flow, binding);

            return(data);
        }
示例#5
0
            public void FirstContextAddsToTable()
            {
                byte[] context = { 74, 68 };
                byte   symbol  = 103;

                var ct = new ContextTable();

                ct.UpdateContext(new Entry(symbol, context));

                Assert.IsTrue(ct.ContainsKey(context));
            }
示例#6
0
            public void NoContextAddsFifthSymbolToTable()
            {
                byte symbol = 100; // d -> expected = 104
                var  ct     = new ContextTable();


                for (var i = 0; i <= 5; i++)
                {
                    ct.UpdateContext(new Entry((byte)(symbol + i), new byte[0]));
                }

                Assert.IsTrue(ct[new byte[0]].ContainsKey(104));
            }
        public void CreateSchema()
        {
            Console.WriteLine("Cassandra Linq: Changing the keyspace.");

            const string keyspaceName = "labyrinth_linq";

            session.DeleteKeyspaceIfExists(keyspaceName);
            session.CreateKeyspaceIfNotExists(keyspaceName);
            session.ChangeKeyspace(keyspaceName);

            Console.WriteLine("Cassandra Linq: Creating the context and the tables.");

            labyrinthContext = new LabyrinthContext(session);
            connectionTable  = labyrinthContext.GetTable <Connection>();
            bookTable        = labyrinthContext.GetTable <Book>();

            Console.WriteLine("Cassandra Linq: Schema created.");
        }
示例#8
0
            public void SymbolListHasCorrectCountsInMiddleContext()
            {
                byte[] letterArray = { 61, 62, 63, 64, 65, 66, 67, 68, 69, 70 }; // 10 elements: 'a - j'
                byte[] context1    = { 74, 68 };
                byte[] context2    = { 42, 77 };
                byte[] context3    = { 55, 22 };

                var expected = 20;
                var e        = new Entry {
                    Context = context1
                };
                var e2 = new Entry {
                    Context = context2
                };
                var e3 = new Entry {
                    Context = context3
                };

                var orderX = new ContextTable();

                foreach (var t in letterArray)
                {
                    e.Symbol = t;
                    orderX.UpdateContext(e);
                }

                foreach (var t in letterArray)
                {
                    e2.Symbol = t;
                    orderX.UpdateContext(e2);
                }

                foreach (var t in letterArray)
                {
                    e3.Symbol = t;
                    orderX.UpdateContext(e3);
                }


                var actual = orderX[context2].Sum(p => p.Value.Count) + orderX[context2].EscapeInfo.Count;

                Assert.AreEqual(expected, actual);
            }
示例#9
0
        private ContextTable CreateContextTable()
        {
            MyPerson person1 = new MyPerson();

            person1.Age  = 30;
            person1.Name = "Person";
            MyPerson person2 = new MyPerson();

            person2.Age  = 30;
            person2.Name = "Person";
            MyPerson person3 = new MyPerson();

            person3.Age  = 40;
            person3.Name = "Person3";
            ContextTable table = new ContextTable();

            table.Add("Person1", person1);
            table.Add("Person2", person2);
            table.Add("Person3", person3);
            return(table);
        }
示例#10
0
            public void CumCountIncrementsBy1()
            {
                byte[] letterArray = { 61, 62 };
                byte[] context     = { 74, 68 };
                var    expected    = 1;
                var    e           = new Entry {
                    Context = context
                };

                var orderX = new ContextTable();

                foreach (var t in letterArray)
                {
                    e.Symbol = t;
                    orderX.UpdateContext(e);
                }

                var actual = orderX[context][letterArray[1]].CumulativeCount -
                             orderX[context][letterArray[0]].CumulativeCount;

                Assert.AreEqual(expected, actual);
            }
示例#11
0
            public void UpdateCumCountWithTwoSymbolArrays()
            {
                byte letter = 65; // A

                byte[] context  = { 74, 68 };
                byte[] context2 = { 68, 61 };
                var    expected = 4 * 10;

                var e = new Entry {
                    Context = context
                };
                var e2 = new Entry {
                    Context = context2
                };

                var orderX = new ContextTable();

                for (byte i = 0; i < 10; i++)
                {
                    e.Symbol = (byte)(letter + i);
                    orderX.UpdateContext(e);
                }

                for (var i = 0; i < 10; i++)
                {
                    e2.Symbol = (byte)(letter + i);
                    orderX.UpdateContext(e2);
                }

                var actual = 0;

                foreach (var t in orderX)
                {
                    actual += t.Value.TotalCount;
                }

                Assert.AreEqual(expected, actual);
            }
示例#12
0
            public void UpdateCumCountIncrementsCumulativeCount()
            {
                byte letter  = 65;
                byte letter2 = 66;

                byte[] context  = { 74, 68 };
                var    expected = 1;
                var    orderX   = new ContextTable();

                var e = new Entry(letter, context);

                orderX.UpdateContext(e);
                orderX[context].CalculateCumulativeCounts();
                var first = orderX[context][letter].CumulativeCount;

                e.Symbol = letter2;
                orderX.UpdateContext(e);
                orderX[context].CalculateCumulativeCounts();
                var second = orderX[context][letter2].CumulativeCount;
                var actual = second - first;

                Assert.AreEqual(expected, actual);
            }
示例#13
0
 public ValidationData(ContextTable contexts, ValidationFlow flow, BindingContainer binding)
 {
     this.Contexts         = contexts;
     this.flow             = flow;
     this.bindingContainer = binding;
 }