namespace LaaProduction.Data.Cordonel.UnitTests.Mock { using System; using System.Collections.Generic; internal static class SentinelTestContextExtensions { public static T TryGetValue(this Dictionary data, string key) { if (string.IsNullOrWhiteSpace(key)) { throw new InvalidOperationException($"{nameof(key)} ist erforderlich"); } else if (!data.TryGetValue(key, out var t)) { throw new InvalidOperationException($"{nameof(key)}: {typeof(T).Name} ist nicht vorhanden"); } else if (t is T _object) { return _object; } else { throw new InvalidOperationException($"{nameof(key)}: value ist nicht von typ {typeof(T).Name}"); } } } }