コード例 #1
0
        public async Task Remove_Clear_Key_Test()
        {
            var key   = nameof(ObjectTestClass);
            var value = new ObjectTestClass()
            {
                Name = "zhangsan",
                Age  = 18
            };

            // remove test
            await _cache.SetAsync(key, value);

            await _cache.RemoveAsync(key);

            var removeValue = await _cache.GetAsync <ObjectTestClass>(key);

            removeValue.ShouldBeNull();

            // clear test
            await _cache.SetAsync(key, value);

            await _cache.ClearAsync();

            var clearValue = await _cache.GetAsync <ObjectTestClass>(key);

            clearValue.ShouldBeNull();
        }
コード例 #2
0
ファイル: ObjectTests.cs プロジェクト: jmbeach/h-extensions
        public void DetailedObjectStringComplexTests()
        {
            const string innerVal  = "Inner Value";
            const string stringVal = "Custom String";
            const int    intVal    = 42;

            var testType   = typeof(ObjectTestClass);
            var stringVals = new[] { "Foo", "Bar", "Baz" };
            var innerObj   = new ObjectInnerTestClass(innerVal);
            var outerObj   = new ObjectTestClass(stringVal, intVal, stringVals, innerObj, testType);

            var classDetailedString = outerObj.ToDetailedString("outerObj");

            Assert.IsTrue(!string.IsNullOrEmpty(classDetailedString));

            var lineDelimiter = new[] { Environment.NewLine };
            var detailLines   = classDetailedString.Split(lineDelimiter, StringSplitOptions.RemoveEmptyEntries);

            Assert.IsNotNull(detailLines);
            Assert.AreEqual(detailLines.Length, 9);

            var fooLine = detailLines[4];

            Assert.IsTrue(fooLine.Contains("Foo"));
        }
コード例 #3
0
        public async Task Object_Get_Set_Test()
        {
            var key   = nameof(ObjectTestClass);
            var value = new ObjectTestClass()
            {
                Name = "zhangsan",
                Age  = 18
            };
            await _cache.SetAsync(key, value);

            var objValue = await _cache.GetAsync <ObjectTestClass>(key);

            objValue.Name.ShouldBe(value.Name);
            objValue.Age.ShouldBe(value.Age);
        }
コード例 #4
0
        public void LoadsFromObject()
        {
            var source = new ObjectTestClass
            {
                A = "1",
                B = "2"
            };
            var expected = new Dictionary <string, string>
            {
                { "A", "1" },
                { "B", "2" },
            };

            var actual = new FormValueDictionary(source, settings);

            Assert.Equal(expected, actual);
        }
コード例 #5
0
 public void TestInit()
 {
     this.testClass = new ObjectTestClass(InitFirstNameValue, InitLastNameValue);
 }