private void IncDecTestInner <TData>( bool doSetInitialValue, TData initialValue, TData incrementBy, TData decrementBy, bool doInc, bool doDec, TData expectedIncResult, TData expectedDecResult, TData expectedFinalResult) { var key = TestContext.TestName; if (doSetInitialValue) { Set(key, initialValue); } object incResult = null; object decResult = null; if (typeof(TData) == typeof(long)) { if (doInc) { incResult = redisContext.Increment(key, Convert.ToInt64(incrementBy)); } if (doDec) { decResult = redisContext.Decrement(key, Convert.ToInt64(decrementBy)); } var getResult = TryGet(key, out TData resultValue); if (doInc) { Assert.AreEqual(expectedIncResult, (TData)incResult); } if (doDec) { Assert.AreEqual(expectedDecResult, (TData)decResult); } if (doSetInitialValue || doInc || doDec) { Assert.IsTrue(getResult); } else { Assert.IsFalse(getResult); } Assert.AreEqual(expectedFinalResult, resultValue); } else if (typeof(TData) == typeof(double)) { if (doInc) { incResult = redisContext.Increment(key, Convert.ToDouble(incrementBy)); } if (doDec) { decResult = redisContext.Decrement(key, Convert.ToDouble(decrementBy)); } var getResult = TryGet(key, out TData resultValue); if (doInc) { AssertAreSimilar(Convert.ToDouble(expectedIncResult), Convert.ToDouble(incResult)); } if (doDec) { AssertAreSimilar(Convert.ToDouble(expectedDecResult), Convert.ToDouble(decResult)); } if (doSetInitialValue || doInc || doDec) { Assert.IsTrue(getResult); } else { Assert.IsFalse(getResult); } AssertAreSimilar(Convert.ToDouble(expectedFinalResult), Convert.ToDouble(resultValue)); } else { throw new NotSupportedException($"{nameof(TData)} is not supported"); } }