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(); }
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")); }
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); }
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); }
public void TestInit() { this.testClass = new ObjectTestClass(InitFirstNameValue, InitLastNameValue); }