Created
October 23, 2010 20:26
-
-
Save leandrosilva/642656 to your computer and use it in GitHub Desktop.
Very simple flush, write, read and remove workflow from C# to Redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This code use redis-sharp library by Miguel de Icaza. | |
| http://github.com/migueldeicaza/redis-sharp | |
| That's a very simple test of Redis 2.0.1, Mono 2.8 and C# together on Mac OS X Snow Leopard to rock! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NUnit.Framework; | |
| namespace Database.Tests | |
| { | |
| [TestFixture()] | |
| public class RedisTest | |
| { | |
| [Test()] | |
| public void ShouldReadAndWriteFromRedis() | |
| { | |
| var k = "foo"; | |
| var v = "bar"; | |
| var reddo = new Redis(); | |
| reddo.FlushAll(); | |
| Assert.AreEqual(0, reddo.Keys.Length); | |
| reddo.Set(k, v); | |
| Assert.AreEqual(1, reddo.Keys.Length); | |
| Assert.AreEqual(Redis.KeyType.String, reddo.TypeOf(k)); | |
| Assert.AreEqual(v, reddo.GetString(k)); | |
| reddo.Remove(k); | |
| Assert.AreEqual(0, reddo.Keys.Length); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment