Beispiel #1
0
        public void CraftTreePath_WhenAddingNodeToRoot_NoStepsGiven(string path, string id)
        {
            var cPath = new CraftTreePath(path, id);

            Assert.IsNull(cPath.StepsToParentTab);
            Assert.IsTrue(cPath.IsAtRoot);
        }
Beispiel #2
0
        public override bool SendToSMLHelper()
        {
            QuickLogger.Debug($"CraftingNodePath for {this.Key} '{this.TabID}' set to {this.ParentTabPath}");
            try
            {
                if (this.IsAtRoot)
                {
                    this.ParentFabricator.RootNode.AddTabNode(this.TabID, this.DisplayName, GetCraftingTabSprite());
                }
                else
                {
                    CraftTreePath craftTreePath = GetCraftTreePath();
                    if (craftTreePath.HasError)
                    {
                        QuickLogger.Error($"Encountered error in path for '{this.TabID}' - Entry from {this.Origin} - Error Message: {this.CraftingPath.Error}");
                        return(false);
                    }

                    ModCraftTreeTab otherTab = this.ParentFabricator.RootNode.GetTabNode(craftTreePath.StepsToParentTab);
                    otherTab.AddTabNode(this.TabID, this.DisplayName, GetCraftingTabSprite());
                }

                return(true);
            }
            catch (Exception ex)
            {
                QuickLogger.Error($"Exception thrown while handling {this.Key} '{this.TabID}' from {this.Origin}", ex);
                return(false);
            }
        }
Beispiel #3
0
        public void CraftTreePath_WhenRemovingNode_CheckPathForRemoval(string path, string id, int expectedStepCount)
        {
            var cPath = new CraftTreePath(path, id);

            string[] stepsToNode = cPath.StepsToNode;
            Assert.AreEqual(expectedStepCount, stepsToNode.Length);
            Assert.AreEqual(id, stepsToNode[expectedStepCount - 1]);
        }
Beispiel #4
0
        public void CraftTreePath_WhenAddingNodeNotAtRoot_CheckPathForAddition(string path, string id, int expectedStepCount)
        {
            var cPath = new CraftTreePath(path, id);

            string[] stepsToParent = cPath.StepsToParentTab;
            Assert.AreEqual(expectedStepCount, stepsToParent.Length);
            Assert.AreNotEqual(id, stepsToParent[expectedStepCount - 1]);
            Assert.IsFalse(cPath.IsAtRoot);
        }
Beispiel #5
0
        public void CraftTreePath_GivenPathAndNode_GetExpectedIsAtRoot(string path, string id, bool shouldBeRoot)
        {
            var cPath = new CraftTreePath(path, id);

            Assert.AreEqual(shouldBeRoot, cPath.IsAtRoot);
        }
Beispiel #6
0
        public void CraftTreePath_GivenPathAndNode_GetExpectedScheme(string path, string id, CraftTree.Type expectedScheme)
        {
            var cPath = new CraftTreePath(path, id);

            Assert.AreEqual(expectedScheme, cPath.Scheme);
        }