예제 #1
0
        public void ClearTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.Clear();
            map.Count.AreEqualWith(0);
        }
예제 #2
0
        public void ContainsKeyTwoTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.ContainsKeyTwo("a").IsTrue();
            map.ContainsKeyTwo("p").IsFalse();
        }
예제 #3
0
        public void ContainsKeyOneTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.ContainsKeyOne(1).IsTrue();
            map.ContainsKeyOne(10).IsFalse();
        }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        currentTerrainID = new int[2];
        terrainBuffer    = new Terrain[TERRAIN_BUFFER_COUNT];
        terrainUsage     = new DoubleKeyDictionary <int, int, int>();
        terrainUsageData = new DoubleKeyDictionary <int, int, TerrainData>();
        usedTiles        = new BitArray(TERRAIN_BUFFER_COUNT, false);
        touchedTiles     = new BitArray(TERRAIN_BUFFER_COUNT, false);

        referencePosition = referenceTerrain.transform.position;
        referenceRotation = referenceTerrain.transform.rotation;
        referenceSize     = new Vector2(referenceTerrain.terrainData.size.x, referenceTerrain.terrainData.size.z);

        for (int i = 0; i < TERRAIN_BUFFER_COUNT; i++)
        {
            terrainBuffer[i] = Instantiate(referenceTerrain);

            /*
             * TerrainData tData = new TerrainData();
             * CopyTerrainDataFromTo(referenceTerrain.terrainData, ref tData);
             *
             *
             * terrainBuffer[i] = Terrain.CreateTerrainGameObject(tData).GetComponent<Terrain>();
             * terrainBuffer[i].castShadows = false;
             * terrainBuffer[i].treeMaximumFullLODCount = 2000;
             * terrainBuffer[i].treeCrossFadeLength= 2000;
             * terrainBuffer[i].treeDistance = 2000;
             * terrainBuffer[i].basemapDistance = 1000;
             * terrainBuffer[i].drawHeightmap = true;*/
            terrainBuffer[i].gameObject.SetActive(false);
        }
    }
예제 #5
0
        public void GetTwoValueTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.GetTwoValue("a").AreEqualWith("Z");
            map.GetTwoValue("b").AreEqualWith("X");
        }
예제 #6
0
        public void SetTwoValueTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.SetTwoValue("a", "O");
            map.GetTwoValue("a").AreEqualWith("O");
            map.GetOneValue(1).AreEqualWith("O");
        }
예제 #7
0
        public void AddTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.Add(9, "p", "O");
            map.ContainsKeyOne(9).IsTrue();
            map.ContainsKeyTwo("p").IsTrue();
        }
        public void Add_SameKeys_Allowed()
        {
            var dict = new DoubleKeyDictionary<string, string, int>();
            dict.Add("1", "1", 2);
            dict.Add("1", "1", 4);

            Assert.IsTrue(dict.ContainsKey("1", "1"));
        }
예제 #9
0
        public void AddTestArgumentNullException()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.Add(8, "p", null);

            map.Add(0, null, "P");
        }
        public void Add_SameKeys_Allowed()
        {
            var dict = new DoubleKeyDictionary <string, string, int>();

            dict.Add("1", "1", 2);
            dict.Add("1", "1", 4);

            Assert.IsTrue(dict.ContainsKey("1", "1"));
        }
        public void Index_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<int, int, int>();
            dict[1, 1] = 2;
            dict[2, 2] = 4;

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Add_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<int, int, int>();
            dict.Add(1, 1, 2);
            dict.Add(2, 2, 4);

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Add_StringAndIntKeys_Works()
        {
            var dict = new DoubleKeyDictionary<string, int, int>();
            dict.Add("1", 1, 2);
            dict.Add("2", 2, 4);

            Assert.IsTrue(dict.ContainsKey("1", 1));
            Assert.IsTrue(dict.ContainsKey("2", 2));
        }
예제 #14
0
        public void RemoveTwoTest()
        {
            DoubleKeyDictionary <int, string, string> map = CreateDictionary();

            map.RemoveTwo("a");
            map.ContainsKeyTwo("a").IsFalse();

            map.RemoveTwo("I");
            map.ContainsKeyTwo("I").IsFalse();
        }
        public void Add_StringAndIntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <string, int, int>();

            dict.Add("1", 1, 2);
            dict.Add("2", 2, 4);

            Assert.IsTrue(dict.ContainsKey("1", 1));
            Assert.IsTrue(dict.ContainsKey("2", 2));
        }
        public void Equals_StringKeys_SameKeys_DifferentValue_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary<string, string, int>();
            var dict2 = new DoubleKeyDictionary<string, string, int>();

            dict1.Add("1", "1", 3);
            dict2.Add("1", "1", 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }
        public void Equals_StringKeys_OneValue_AreEqual()
        {
            var dict1 = new DoubleKeyDictionary<string, string, int>();
            var dict2 = new DoubleKeyDictionary<string, string, int>();

            dict1.Add("1", "1", 2);
            dict2.Add("1", "1", 2);

            Assert.IsTrue(dict1.Equals(dict2));
        }
        public void Equals_IntKeys_OneValue_AreEqual()
        {
            var dict1 = new DoubleKeyDictionary<int, int, int>();
            var dict2 = new DoubleKeyDictionary<int, int, int>();

            dict1.Add(1, 1, 2);
            dict2.Add(1, 1, 2);

            Assert.IsTrue(dict1.Equals(dict2));
        }
예제 #19
0
    public DoubleKeyDictionary <K1, K2, Value> Clone()
    {
        DoubleKeyDictionary <K1, K2, Value> clone = new DoubleKeyDictionary <K1, K2, Value>();

        foreach (K1 key in base.Keys)
        {
            clone.Add(key, this[key].Clone());
        }
        return(clone);
    }
        public void Equals_IntKeys_OneValue_AreEqual()
        {
            var dict1 = new DoubleKeyDictionary <int, int, int>();
            var dict2 = new DoubleKeyDictionary <int, int, int>();

            dict1.Add(1, 1, 2);
            dict2.Add(1, 1, 2);

            Assert.IsTrue(dict1.Equals(dict2));
        }
        public void Equals_IntKeys_DifferentKey1_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary <int, int, int>();
            var dict2 = new DoubleKeyDictionary <int, int, int>();

            dict1.Add(1, 2, 2);
            dict2.Add(2, 2, 3);

            Assert.IsFalse(dict1.Equals(dict2));
        }
        public void Equals_DifferentKeyTypes_SameValue_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary <int, string, int>();
            var dict2 = new DoubleKeyDictionary <string, string, int>();

            dict1.Add(1, "1", 2);
            dict2.Add("1", "1", 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }
        public void Add_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <int, int, int>();

            dict.Add(1, 1, 2);
            dict.Add(2, 2, 4);

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void Equals_IntKeys_DifferentKey1_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary<int, int, int>();
            var dict2 = new DoubleKeyDictionary<int, int, int>();

            dict1.Add(1, 2, 2);
            dict2.Add(2, 2, 3);

            Assert.IsFalse(dict1.Equals(dict2));
        }
 public void ResetDictionary()
 {
     dict = new DoubleKeyDictionary<int, int, int>();
     dict.Add(1, 1, 2);
     dict.Add(2, 1, 3);
     dict.Add(3, 1, 4);
     dict.Add(1, 2, 3);
     dict.Add(1, 3, 4);
     dict.Add(1, 4, 5);
 }
 public void ResetDictionary()
 {
     dict = new DoubleKeyDictionary <int, int, int>();
     dict.Add(1, 1, 2);
     dict.Add(2, 1, 3);
     dict.Add(3, 1, 4);
     dict.Add(1, 2, 3);
     dict.Add(1, 3, 4);
     dict.Add(1, 4, 5);
 }
        public void Equals_StringKeys_OneValue_AreEqual()
        {
            var dict1 = new DoubleKeyDictionary <string, string, int>();
            var dict2 = new DoubleKeyDictionary <string, string, int>();

            dict1.Add("1", "1", 2);
            dict2.Add("1", "1", 2);

            Assert.IsTrue(dict1.Equals(dict2));
        }
        public void Index_IntKeys_Works()
        {
            var dict = new DoubleKeyDictionary <int, int, int>();

            dict[1, 1] = 2;
            dict[2, 2] = 4;

            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.IsTrue(dict.ContainsKey(2, 2));
        }
        public void MissingItemsKeysAreNotFound()
        {
            var key1 = 5;
            var key2 = "key2";

            var dictionary = new DoubleKeyDictionary <int, string, string>();

            var result = dictionary.Contains(key1, key2);

            result.Should().BeFalse();
        }
        public void Equals_IntKeys_MultipleValues_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary <int, int, int>();
            var dict2 = new DoubleKeyDictionary <int, int, int>();

            dict1.Add(1, 1, 2);
            dict1.Add(1, 2, 3);
            dict2.Add(1, 1, 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }
        public void Equals_StringKeys_MultipleValues_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary <string, string, int>();
            var dict2 = new DoubleKeyDictionary <string, string, int>();

            dict1.Add("1", "1", 2);
            dict1.Add("1", "2", 3);
            dict2.Add("1", "1", 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }
        public void Enumerate_IntKeys_ToString_Returns_Key1Key2Value()
        {
            var dict = new DoubleKeyDictionary <string, string, int>();

            dict.Add("a", "b", 1);

            foreach (var item in dict)
            {
                Assert.AreEqual <string>("a - b - 1", item.ToString());
            }
        }
        public void Enumerate_IntKeys_ToString_Returns_Key1Key2Value()
        {
            var dict = new DoubleKeyDictionary<string, string, int>();
            dict.Add("a", "b", 1);

            foreach (var item in dict)
            {
                Assert.AreEqual<string>("a - b - 1", item.ToString());
            }
        
        }
예제 #34
0
        //
        //编写测试时,还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        private DoubleKeyDictionary <int, string, string> CreateDictionary()
        {
            DoubleKeyDictionary <int, string, string> map = new DoubleKeyDictionary <int, string, string>();

            map.Add(1, "a", "Z");
            map.Add(2, "b", "X");
            map.Add(3, "c", "S");
            map.Add(4, "d", "C");
            map.Add(5, "e", "R");

            return(map);
        }
        public void MissingItemIsNotFound()
        {
            var key1 = 5;
            var key2 = "key2";

            var dictionary = new DoubleKeyDictionary <int, string, string>();

            string resultValue = null;
            var    result      = dictionary.TryGetValue(key1, key2, out resultValue);

            result.Should().BeFalse();
            resultValue.Should().BeNull();
        }
        private DoubleKeyDictionary <TKeyId, TKeyName, TValue> Initialize <TKeyId, TKeyName, TValue>(int count)
        {
            var doubleKeyDictionary = new DoubleKeyDictionary <TKeyId, TKeyName, TValue>();
            var typeId    = Nullable.GetUnderlyingType(typeof(TKeyId)) ?? typeof(TKeyId);
            var typeName  = Nullable.GetUnderlyingType(typeof(TKeyName)) ?? typeof(TKeyName);
            var typeValue = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue);

            for (var i = 0; i < count; i++)
            {
                doubleKeyDictionary.Add((TKeyId)Convert.ChangeType(i, typeId, CultureInfo.InvariantCulture), (TKeyName)Convert.ChangeType(i, typeName, CultureInfo.InvariantCulture), (TValue)Convert.ChangeType(i, typeValue, CultureInfo.InvariantCulture));
            }
            return(doubleKeyDictionary);
        }
        public void AddingItemTwiceThrows()
        {
            var key1  = 5;
            var key2  = "key2";
            var value = "asmdpsodfgkhöglhmdfgh d";

            var dictionary = new DoubleKeyDictionary <int, string, string>();

            dictionary.Add(key1, key2, value);

            Action addSecondTime = () => { dictionary.Add(key1, key2, value); };

            addSecondTime.Should().Throw <Exception>();
        }
        public void AddedItemsKeysAreFound()
        {
            var key1  = 5;
            var key2  = "key2";
            var value = "asmdpsodfgkhöglhmdfgh d";

            var dictionary = new DoubleKeyDictionary <int, string, string>();

            dictionary.Add(key1, key2, value);

            var result = dictionary.Contains(key1, key2);

            result.Should().BeTrue();
        }
        public void AddedItemIsFound()
        {
            var key1  = 5;
            var key2  = "key2";
            var value = "asmdpsodfgkhöglhmdfgh d";

            var dictionary = new DoubleKeyDictionary <int, string, string>();

            dictionary.Add(key1, key2, value);

            string resultValue = null;
            var    result      = dictionary.TryGetValue(key1, key2, out resultValue);

            result.Should().BeTrue();
            resultValue.Should().BeSameAs(value);
        }
        public void Add_SameKeys_UpdatesValue()
        {
            var dict = new DoubleKeyDictionary<string, string, int>();

            // add first value
            dict.Add("1", "1", 2);
            var val = dict["1", "1"];
            // assert value is 2
            Assert.AreEqual<int>(2, val);

            // update value
            dict.Add("1", "1", 4);
            val = dict["1", "1"];
            // assert value has been updated to 4
            Assert.AreEqual<int>(4, val);
        }
        public void Add_SameKeys_UpdatesValue()
        {
            var dict = new DoubleKeyDictionary <string, string, int>();

            // add first value
            dict.Add("1", "1", 2);
            var val = dict["1", "1"];

            // assert value is 2
            Assert.AreEqual <int>(2, val);

            // update value
            dict.Add("1", "1", 4);
            val = dict["1", "1"];
            // assert value has been updated to 4
            Assert.AreEqual <int>(4, val);
        }
        public void Equals_StringKeys_MultipleValues_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary<string, string, int>();
            var dict2 = new DoubleKeyDictionary<string, string, int>();

            dict1.Add("1", "1", 2);
            dict1.Add("1", "2", 3);
            dict2.Add("1", "1", 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }
예제 #43
0
    // Use this for initialization
    void Start()
    {
        currentTerrainID = new int[2]{0,0};
        previousTerrainID = new int[2]{0,0};
        tempTerrainID = new int[2]{0,0};
        terrainBuffer = new Terrain[TERRAIN_BUFFER_COUNT];
        terrainUsage = new DoubleKeyDictionary<int, int, int>();
        terrainUsageData = new DoubleKeyDictionary<int, int, TerrainData>();

        hillFactor = new DoubleKeyDictionary<int, int, int>();

        usedTiles = new BitArray(TERRAIN_BUFFER_COUNT, false);
        touchedTiles = new BitArray(TERRAIN_BUFFER_COUNT, false);

        referencePosition = referenceTerrain.transform.position;
        referenceRotation = referenceTerrain.transform.rotation;
        referenceSize = new Vector2(referenceTerrain.terrainData.size.x, referenceTerrain.terrainData.size.z);

        treeBase = referenceTerrain.terrainData.treeInstanceCount;

        tileWidth = referenceTerrain.terrainData.heightmapWidth;
        tileHeight = referenceTerrain.terrainData.heightmapHeight;

        for(int i=0; i<TERRAIN_BUFFER_COUNT; i++){
            TerrainData tData = new TerrainData();
            CopyTerrainDataFromTo(referenceTerrain.terrainData, ref tData);
            terrainBuffer[i] = Terrain.CreateTerrainGameObject(tData).GetComponent<Terrain>();
            terrainBuffer[i].gameObject.SetActive(false);
        }
    }
예제 #44
0
    // Use this for initialization
    void Start()
    {
        currentTerrainID = new int[2];
        terrainBuffer = new Transform[TERRAIN_BUFFER_COUNT];
        terrainUsage = new DoubleKeyDictionary<int, int, int>();
        //terrainUsageData = new DoubleKeyDictionary<int, int, TerrainData>();
        usedTiles = new BitArray(TERRAIN_BUFFER_COUNT, false);
        touchedTiles = new BitArray(TERRAIN_BUFFER_COUNT, false);

        referencePosition = referenceTerrain.transform.position;
        referenceRotation = referenceTerrain.transform.rotation;
        //referenceSize = new Vector2(referenceTerrain.terrainData.size.x, referenceTerrain.terrainData.size.z);
        referenceSize = new Vector2(referenceTerrain.transform.localScale.x, referenceTerrain.transform.localScale.z);

        for(int i=0; i<TERRAIN_BUFFER_COUNT; i++)
        {
            //TerrainData tData = new TerrainData();
            //CopyTerrainDataFromTo(referenceTerrain.terrainData, ref tData);
            //terrainBuffer[i] = Terrain.CreateTerrainGameObject(tData).GetComponent<Terrain>();
            //terrainBuffer[i] = GameObject.CreatePrimitive(PrimitiveType.Cube);
            terrainBuffer[i] = (Transform)Instantiate(referenceTerrain);
            terrainBuffer[i].localScale = new Vector3(referenceSize.x, 1, referenceSize.y);
            terrainBuffer[i].gameObject.SetActive(false);
        }
    }
        public void Equals_IntKeys_MultipleValues_NotEqual()
        {
            var dict1 = new DoubleKeyDictionary<int, int, int>();
            var dict2 = new DoubleKeyDictionary<int, int, int>();

            dict1.Add(1, 1, 2);
            dict1.Add(1, 2, 3);
            dict2.Add(1, 1, 2);

            Assert.IsFalse(dict1.Equals(dict2));
        }