Beispiel #1
0
        public void ModificationsOfNodeInfoOutsideArePreserved()
        {
            GameTreeNode node = new GameTreeNode();
            var          info = node.GetOrCreateNodeInfo <TestGameTreeNodeInfo>();

            info.TestInfo = "new value";
            var newInfo = node.GetOrCreateNodeInfo <TestGameTreeNodeInfo>();

            Assert.AreEqual("new value", newInfo.TestInfo);
        }
Beispiel #2
0
        public void CustomNodeInfoCanBeCreatedWithFunctor()
        {
            GameTreeNode node = new GameTreeNode();
            var          info = node.GetOrCreateNodeInfo(() => new TestGameTreeNodeInfo("test"));

            Assert.IsNotNull(info);
            Assert.AreEqual("test", info.TestInfo);
        }
Beispiel #3
0
        public void CustomNodeInfoCanBeCreatedAutomatically()
        {
            GameTreeNode node = new GameTreeNode(Move.NoneMove);
            var          info = node.GetOrCreateNodeInfo <TestGameTreeNodeInfo>();

            Assert.IsNotNull(info);
            Assert.AreEqual("hello", info.TestInfo);
        }
Beispiel #4
0
        public void NodeInfoIsNotRecreatedWithFunctor()
        {
            GameTreeNode node = new GameTreeNode();
            var          info = new TestGameTreeNodeInfo("custom");

            node.SetNodeInfo(info);
            var retrievedInfo = node.GetOrCreateNodeInfo(() => new TestGameTreeNodeInfo("different"));

            Assert.IsNotNull(retrievedInfo);
            Assert.AreEqual("custom", retrievedInfo.TestInfo);
        }
Beispiel #5
0
        public void NodeInfoIsNotRecreated()
        {
            GameTreeNode node = new GameTreeNode();
            var          info = new TestGameTreeNodeInfo("custom");

            node.SetNodeInfo(info);
            var retrievedInfo = node.GetOrCreateNodeInfo <TestGameTreeNodeInfo>();

            Assert.IsNotNull(retrievedInfo);
            Assert.AreEqual("custom", retrievedInfo.TestInfo);
        }