Esempio n. 1
0
        public static void UT2()
        {
            DicStorage <int, LayerData> storage = new DicStorage <int, LayerData>(
                (a) => { return(a.Key1); },
                () =>
            {
                return(new DicObjectStorage <int, LayerData>((a) => { return a.Key2; }));
            });

            LayerData ldA = new LayerData()
            {
                Key1 = 1, Key2 = 2
            };

            storage.Insert(ldA);
            System.Diagnostics.Debug.Assert(storage.Count == 1);

            LayerData ldB = new LayerData()
            {
                Key1 = 2, Key2 = 3
            };

            storage.Insert(ldB);
            System.Diagnostics.Debug.Assert(storage.Count == 2);

            LayerData ldC = new LayerData()
            {
                Key1 = 2, Key2 = 3, Data = 100
            };

            storage.Update(ldC);
        }
Esempio n. 2
0
        public static void UT4()
        {
            DicStorage <int, int> storage = new DicStorage <int, int>(
                (a) => { return(a); }, () => { return(new NativeStorage <int>()); });

            storage.Insert(10);
            System.Diagnostics.Debug.Assert(storage.Count == 1);
            storage.Insert(20);
            System.Diagnostics.Debug.Assert(storage.Count == 2);
            storage.Insert(10);
            System.Diagnostics.Debug.Assert(storage.Count == 2);

            storage.Delete(10);
            System.Diagnostics.Debug.Assert(storage.Count == 1);

            int[] allData = storage.ToArray();

            storage.Insert(20);
            storage.Clear();
            System.Diagnostics.Debug.Assert(storage.Count == 0);
        }