public void GetReturnsObjectFromGlobalStateForDifferentTypes()
        {
            IGlobalState state = new GlobalState();

            state.Add("test", 8);
            state.Add("test2", "Steve");

            Assert.AreEqual(8, (int)state.Get("test"));
            Assert.AreEqual("Steve", (string)state.Get("test2"));
        }
        public void GetReturnsObjectFromGlobalState()
        {
            IGlobalState state = new GlobalState();

            int testNumber = 8;

            state.Add("test", testNumber);

            Assert.AreEqual(testNumber, (int)state.Get("test"));
            Assert.AreEqual(8, (int)state.Get("test"));
        }
        public void UpdateValueInStateObjectWithMixedCase()
        {
            IGlobalState state = new GlobalState();

            state.Add("counter", 0);

            Assert.AreEqual(0, (int)state.Get("Counter"));

            var counter = (int)state.Get("CoUnTer");

            counter++;
            state.Update("counTeR", counter);

            Assert.AreEqual(1, (int)state.Get("cOuNtEr"));
        }
        public void UpdateValueInStateObject()
        {
            IGlobalState state = new GlobalState();

            state.Add("counter", 0);

            Assert.AreEqual(0, (int)state.Get("counter"));

            var counter = (int)state.Get("counter");

            counter++;
            state.Update("counter", counter);

            Assert.AreEqual(1, (int)state.Get("counter"));
        }
Beispiel #5
0
        /**
         * Builds the DOM element for a global state
         *
         * @param globalState
         * @return
         */

        protected void FillNode(XmlNode node, GlobalState globalState, params IDOMWriterParam[] options)
        {
            XmlElement conditionsNode = node as XmlElement;

            // Create the necessary elements to create the DOM
            XmlDocument doc = Writer.GetDoc();

            conditionsNode.SetAttribute("id", globalState.getId());
            XmlNode documentationNode = doc.CreateElement("documentation");

            documentationNode.AppendChild(doc.CreateTextNode(globalState.getDocumentation()));
            conditionsNode.AppendChild(documentationNode);

            // Iterate all the condition'blocks
            for (int i = 0; i < globalState.Size(); i++)
            {
                var block = globalState.Get(i);
                // Single condition
                if (block.Count == 1)
                {
                    XmlElement conditionElement = createConditionElement(doc, block[0]);
                    doc.ImportNode(conditionElement, true);
                    conditionsNode.AppendChild(conditionElement);
                }
                else if (block.Count > 1)
                {
                    XmlNode eitherNode = createElementWithList("either", block);
                    doc.ImportNode(eitherNode, true);
                    conditionsNode.AppendChild(eitherNode);
                }
            }
        }
        public void AddInsertsObjectInGameState()
        {
            IGlobalState state = new GlobalState();

            int testNumber = 8;

            state.Add("test", testNumber);

            Assert.AreEqual(1, state.Count());
            Assert.AreEqual(testNumber, (int)state.Get("test"));
        }