Example #1
0
        public void TestStateCodeGeneration()
        {
            ICodeBlock codeBlock = new CodeDocument(0);

            mButtonInButtonList.CurrentState = "InvalidState";

            StateCodeGenerator.WriteSetStateOnNamedObject(mButtonInButtonList, codeBlock);
            string result = codeBlock.ToString();

            if (result.Contains(mButtonInButtonList.CurrentState))
            {
                throw new Exception("Code generation for NamedObjects is generating state setting code when states don't really exist");
            }

            // Make sure generation doesn't mess up on a entity with a "" base (instead of null)
            StateCodeGenerator scg        = new StateCodeGenerator();
            EntitySave         entitySave = new EntitySave();

            entitySave.States.Add(new StateSave());

            entitySave.BaseEntity = "";
            scg.GenerateFields(codeBlock, entitySave);
        }