public void TestCreateVariable() { TestVariableMapSetup(); mVariableMap.CreateVariable("name1", "type1", "id1"); TestHelper.CheckVariableValues(mVariableMap, "name1", "type1", "id1"); //test create variable already exists---------------------------------------- //Expect that when the variable already exists, the variableMap_ is unchanged. Assert.AreEqual(1, mVariableMap.GetVariableTypes().Count); Assert.AreEqual(1, mVariableMap.GetAllVariables().Count); mVariableMap.CreateVariable("name1"); TestHelper.CheckVariableValues(mVariableMap, "name1", "type1", "id1"); Assert.AreEqual(1, mVariableMap.GetVariableTypes().Count); Assert.AreEqual(1, mVariableMap.GetAllVariables().Count); //--------------------------------------------------------------------------- //test create variable null and undefined type------------------------------- mVariableMap.CreateVariable("name2", null, "id2"); mVariableMap.CreateVariable("name3", "", "id3"); TestHelper.CheckVariableValues(mVariableMap, "name2", "", "id2"); TestHelper.CheckVariableValues(mVariableMap, "name3", "", "id3"); //--------------------------------------------------------------------------- //test create variable null id----------------------------------------------- mVariableMap.CreateVariable("name4", "type4", null); Assert.NotNull(mVariableMap.GetVariable("name4").ID); //--------------------------------------------------------------------------- //test create VariableId already exists-------------------------------------- Assert.Throws <Exception>(() => { mVariableMap.CreateVariable("name5", "type5", "id1"); }); //--------------------------------------------------------------------------- //test create Variable mismatched Id and type-------------------------------- Assert.Throws <Exception>(() => { mVariableMap.CreateVariable("name1", "type2", "id1"); }); Assert.Throws <Exception>(() => { mVariableMap.CreateVariable("name1", "type1", "id2"); }); //--------------------------------------------------------------------------- //test create variable two same types---------------------------------------- mVariableMap.CreateVariable("name6", "type6", "id6"); mVariableMap.CreateVariable("name7", "type6", "id7"); TestHelper.CheckVariableValues(mVariableMap, "name6", "type6", "id6"); TestHelper.CheckVariableValues(mVariableMap, "name7", "type6", "id7"); //--------------------------------------------------------------------------- TestVariableMapTearDown(); }