Testing and the Mock RedisContext - adhtalbo/RedisContext GitHub Wiki

The RedisContext also includes a mock version of itself for testing. This allows tests to be run without having Redis running. The mock context writes all calls to an underlying SortedDictionary to emulate the RedisContext functionality.

To create a mock RedisContext you call RedisContextMock<T>.Create

var mockContext = RedisContextMock<ExampleContext>.Create();

Testing migrations

You can also test migrations using the mock RedisContext. This is done by calling RedisSetMock.MigrateFrom

var oldEntity = new BasicEntityOld(){
    // Some values here
};
var newEntity = RedisSetMock<BasicEntity>.MigrateFrom<BasicEntityOld>(oldEntity)
//Assert migration methods have called correctly here