public void Caching_Persist_Should_Leave_Previous_Entries_Intact() { var storage = new Cactus.Blade.Caching.Caching(); var key1 = Guid.NewGuid().ToString(); var value1 = "Some kind of monster"; storage.Store(key1, value1); storage.Persist(); var key2 = Guid.NewGuid().ToString(); var value2 = "Some kind of monster"; storage.Store(key2, value2); storage.Persist(); var target1 = storage.Get <string>(key1); var target2 = storage.Get <string>(key2); target1.Should().Be(value1); target2.Should().Be(value2); }
public void Caching_Store_Should_Persist_And_Retrieve_Correct_Type() { var key = Guid.NewGuid().ToString(); var value = (double)42.4m; var storage = new Cactus.Blade.Caching.Caching(); storage.Store(key, value); storage.Persist(); var target = storage.Get <double>(key); target.Should().Be(value); }
public void Caching_Store_Should_Persist_Simple_DateTime_As_Struct() { var key = Guid.NewGuid().ToString(); var expectedValue = DateTime.Now; var storage = new Cactus.Blade.Caching.Caching(); storage.Store(key, expectedValue); storage.Persist(); var target = storage.Get <DateTime>(key); target.Should().Be(expectedValue); }
public void Caching_Store_Should_Persist_Multiple_Values() { var key1 = Guid.NewGuid().ToString(); var key2 = Guid.NewGuid().ToString(); var key3 = Guid.NewGuid().ToString(); var value1 = "It was the best of times, it was the worst of times."; var value2 = DateTime.Now; var value3 = int.MaxValue; var storage = new Cactus.Blade.Caching.Caching(); storage.Store(key1, value1); storage.Store(key2, value2); storage.Store(key3, value3); storage.Persist(); var target1 = storage.Get <string>(key1); var target2 = storage.Get <DateTime>(key2); var target3 = storage.Get <int>(key3); target1.Should().Be(value1); target2.Should().Be(value2); target3.Should().Be(value3); }
public void Caching_Store_Should_Persist_Simple_String() { var key = Guid.NewGuid().ToString(); var expectedValue = "I-AM-GROOT"; var storage = new Cactus.Blade.Caching.Caching(); storage.Store(key, expectedValue); storage.Persist(); var target = storage.Get(key); target.Should().BeOfType <string>(); target.Should().Be(expectedValue); }
public void Caching_Store_Should_Support_Unicode() { var key = Guid.NewGuid().ToString(); const string expectedValue = "Juliën's Special Characters: ~!@#$%^&*()œōøęsæ"; var storage = new Cactus.Blade.Caching.Caching(); storage.Store(key, expectedValue); storage.Persist(); var target = storage.Get(key); target.Should().BeOfType <string>(); target.Should().Be(expectedValue); }
public void Caching_Should_Remain_Intact_Between_Multiple_Instances() { var storage1 = new Cactus.Blade.Caching.Caching(); var key1 = Guid.NewGuid().ToString(); var value1 = "Robert Baratheon"; storage1.Store(key1, value1); storage1.Persist(); var storage2 = new Cactus.Blade.Caching.Caching(); var key2 = Guid.NewGuid().ToString(); var value2 = "Ned Stark"; storage2.Store(key2, value2); storage2.Persist(); var storage3 = new Cactus.Blade.Caching.Caching(); var target1 = storage3.Get <string>(key1); var target2 = storage3.Get <string>(key2); target1.Should().Be(value1); target2.Should().Be(value2); }
public void Caching_Store_Should_Overwrite_Existing_Key() { const string key = "I-Will-Be-Used-Twice"; var storage = new Cactus.Blade.Caching.Caching(); var original_value = new Joke { Id = 1, Text = "Yo mammo is so fat..." }; storage.Store(key, original_value); storage.Persist(); var expected_value = new Joke { Id = 2, Text = "... she left the house in high heels and when she came back she had on flip flops" }; storage.Store(key, expected_value); storage.Persist(); var target = storage.Get <Joke>(key); target.Should().NotBeNull(); target.IsSameOrEqualTo(expected_value); }