/// <returns>failed</returns> private static bool AddOrReplaceService <T>(T service, bool expectException) where T : class { try { ServiceLocator.AddOrReplaceService <T>(service); if (!expectException) { return(true); } Debug.Log("Expected exception, but service got added anyway"); return(false); } catch (Exception ex) { if (ex is KeyNotFoundException) { if (!expectException) { Debug.Log(ex); return(false); } Debug.Log("Correctly failed to add " + typeof(T).Name); return(true); } Debug.Log(ex); return(false); } }