Esempio n. 1
0
        public void Driver_Table_Calls_Into_Node_With_PreviousTable()
        {
            var nodeBuilder = NodeStateTable <int> .Empty.ToBuilder();

            nodeBuilder.AddEntries(ImmutableArray.Create(1, 2, 3), EntryState.Cached);
            var newTable = nodeBuilder.ToImmutableAndFree();

            NodeStateTable <int>?passedIn     = null;
            CallbackNode <int>   callbackNode = new CallbackNode <int>((b, s) =>
            {
                passedIn = s;
                return(newTable);
            });

            // empty first time
            DriverStateTable.Builder builder = GetBuilder(DriverStateTable.Empty);
            builder.GetLatestStateTableForNode(callbackNode);

            Assert.Same(NodeStateTable <int> .Empty, passedIn);

            // gives the returned table the second time around
            DriverStateTable.Builder builder2 = GetBuilder(builder.ToImmutable());
            builder2.GetLatestStateTableForNode(callbackNode);

            Assert.NotNull(passedIn);
            AssertTableEntries(passedIn !, new[] { (1, EntryState.Cached), (2, EntryState.Cached), (3, EntryState.Cached) });
Esempio n. 2
0
        public void Driver_Table_Calls_Into_Node_With_EmptyState_FirstTime()
        {
            NodeStateTable <int>?passedIn     = null;
            CallbackNode <int>   callbackNode = new CallbackNode <int>((b, s) =>
            {
                passedIn = s;
                return(s);
            });

            DriverStateTable.Builder builder = GetBuilder(DriverStateTable.Empty);
            builder.GetLatestStateTableForNode(callbackNode);

            Assert.Same(NodeStateTable <int> .Empty, passedIn);
        }
Esempio n. 3
0
        public void Driver_Table_Calls_Into_Node_With_Self()
        {
            DriverStateTable.Builder?passedIn     = null;
            CallbackNode <int>       callbackNode = new CallbackNode <int>((b, s) =>
            {
                passedIn = b;
                return(s);
            });

            DriverStateTable.Builder builder = GetBuilder(DriverStateTable.Empty);
            builder.GetLatestStateTableForNode(callbackNode);

            Assert.Same(builder, passedIn);
        }