Exemplo n.º 1
0
        public void Clone_ObjectsWith3Params_ReturnsFullObjectCopy()
        {
            SystemParams systemParams = GetDefaultWith3Params();

            SystemParams cloned = systemParams.Clone();

            Assert.AreEqual(cloned.Count, systemParams.Count);
            Assert.AreEqual(cloned.DisplayText[0], systemParams.DisplayText[0]);
            Assert.AreEqual(cloned.DisplayText[1], systemParams.DisplayText[1]);
            Assert.AreEqual(cloned.ImageIndex, systemParams.ImageIndex);
            Assert.AreEqual(cloned.IsFilled, systemParams.IsFilled);
            Assert.AreEqual(cloned.SaveAsLuaTable(string.Empty),
                            systemParams.SaveAsLuaTable(string.Empty));

            var systemParamArr       = (SystemParam[])systemParams.Items;
            var clonedSystemParamArr = (SystemParam[])cloned.Items;

            for (int i = 0; i < systemParamArr.Length; i++)
            {
                Assert.AreEqual(systemParamArr[i].Name,
                                clonedSystemParamArr[i].Name);
                Assert.AreEqual(systemParamArr[i].LuaName,
                                clonedSystemParamArr[i].LuaName);
                Assert.AreEqual(systemParamArr[i].Meter,
                                clonedSystemParamArr[i].Meter);
            }
        }
Exemplo n.º 2
0
        public void SaveAsLuaTable_EmptyObject_ReturnsEmptyString(
            string prefix)
        {
            var systemParam = new SystemParams();

            string savedCode = systemParam.SaveAsLuaTable(prefix);

            Assert.IsEmpty(savedCode);
        }
Exemplo n.º 3
0
        public void SaveAsLuaTable_ObjectWith3Params_ReturnsCodeLuaForSave(
            string prefix)
        {
            SystemParams systemParams = GetDefaultWith3Params();
            string       expectedCode = string.Empty;

            expectedCode += prefix + "system_parameters" + " =\n";
            expectedCode += prefix + "\t{\n";
            var systemParamArr = (SystemParam[])systemParams.Items;

            foreach (var systemParam in systemParamArr)
            {
                expectedCode += systemParam.SaveAsLuaTable(prefix + "\t");
            }
            expectedCode += prefix + "\t},\n";

            string savedCode = systemParams.SaveAsLuaTable(prefix);

            Assert.AreEqual(expectedCode, savedCode);
        }