Пример #1
0
        public void op_Clear()
        {
            var obj = new WebCacheCollection
            {
                { AlphaDecimal.Random(), new object() }
            };

            Assert.Equal(1, obj.Count);
            obj.Clear();
            Assert.Equal(0, obj.Count);
        }
Пример #2
0
        public void op_ContainsKey_string_whenFalse()
        {
            var obj = new WebCacheCollection();

            try
            {
                obj[AlphaDecimal.Random()] = new object();

                Assert.False(obj.ContainsKey(AlphaDecimal.Random()));
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #3
0
        public void prop_Count_get()
        {
            var obj = new WebCacheCollection();

            try
            {
                Assert.Equal(0, obj.Count);
                obj.Add(AlphaDecimal.Random(), new object());
                Assert.Equal(1, obj.Count);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #4
0
        public void op_Set_string_object_TimeSpan()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key = AlphaDecimal.Random();
                obj.Set(key, new object(), new TimeSpan(123456));

                Assert.True(obj.ContainsKey(key));
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #5
0
        public void op_ContainsKey_string_whenTrue()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key = AlphaDecimal.Random();
                obj[key] = new object();

                Assert.True(obj.ContainsKey(key));
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #6
0
        public void op_Set_string_object_DateTime()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key = AlphaDecimal.Random();
                obj.Set(key, new object(), DateTime.UtcNow.AddDays(1));

                Assert.True(obj.ContainsKey(key));
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #7
0
        public void op_Get_string_FuncObject_whenMissing()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key    = AlphaDecimal.Random();
                var actual = obj.Get(key, AddObject);

                Assert.NotNull(actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #8
0
        public void op_Get_string_FuncICacheCollectionT_whenMissing()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key    = AlphaDecimal.Random();
                var actual = obj.Get <DateTime>(key, AddToCacheOfT <DateTime>);

                Assert.NotNull(actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #9
0
        public void op_Get_string_FuncT_whenMissing()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = default(DateTime);
                var actual   = obj.Get <DateTime>(key, AddOfT <DateTime>);

                Assert.Equal(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #10
0
        public void op_Add_string_object_TimeSpan()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj.Add(key, expected, new TimeSpan(12345));
                var actual = obj[key];

                Assert.Same(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #11
0
        public void op_Add_string_object_DateTime()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj.Add(key, expected, DateTime.UtcNow.AddDays(1));
                var actual = obj[key];

                Assert.Same(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #12
0
        public void indexer_string()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj[key] = expected;
                var actual = obj[key];

                Assert.Same(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #13
0
        public void op_GetOfT_string()
        {
            var obj = new WebCacheCollection();

            try
            {
                var       key      = AlphaDecimal.Random();
                const int expected = 123;
                obj[key] = expected;
                var actual = obj.Get <int>(key);

                Assert.Equal(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #14
0
        public void op_GetEnumerator()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj[key] = expected;
                var actual = obj.First();

                Assert.Same(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #15
0
        public void op_Remove_string()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj[key] = expected;
                var actual = obj.Remove(key);

                Assert.False(obj.ContainsKey(key));
                Assert.Same(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #16
0
        public void op_RemoveOfT_string()
        {
            var obj = new WebCacheCollection();

            try
            {
                var       key      = AlphaDecimal.Random();
                const int expected = 123;
                obj[key] = expected;
                var actual = obj.Remove <int>(key);

                Assert.False(obj.ContainsKey(key));
                Assert.Equal(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #17
0
        public void op_Get_string_FuncObject()
        {
            var obj = new WebCacheCollection();

            try
            {
                var key      = AlphaDecimal.Random();
                var expected = new object();
                obj[key] = expected;

                var actual = obj.Get(key, AddObject);

                Assert.Equal(expected, actual);
            }
            finally
            {
                obj.Clear();
            }
        }
Пример #18
0
        public void op_Get_string_FuncTNull()
        {
            var obj = new WebCacheCollection();

            Assert.Throws <ArgumentNullException>(() => obj.Get(AlphaDecimal.Random(), null as Func <DateTime>));
        }