public void ConfigureHookLogging() { bool called = false; Yogi.LogToHookFnDelegate fn = (Yogi.Verbosity severity, Yogi.Timestamp timestamp, int tid, string file, int line, string comp, string msg) => { Assert.Equal(Yogi.Verbosity.Trace, severity); Assert.Equal(12345L, timestamp.DurationSinceEpoch.NanosecondsCount); Assert.Equal(555, tid); Assert.Equal("foo", file); Assert.Equal(111, line); Assert.Equal("bar", comp); Assert.Equal("hello", msg); called = true; }; MOCK_ConfigureHookLogging((int verbosity, ConfigureHookLoggingFnDelegate fn_, IntPtr userarg) => { Assert.Equal((int)Yogi.Verbosity.Info, verbosity); Assert.NotNull(fn_); fn_((int)Yogi.Verbosity.Trace, 12345, 555, "foo", 111, "bar", "hello", userarg); return((int)Yogi.ErrorCode.Ok); }); Yogi.ConfigureHookLogging(Yogi.Verbosity.Info, fn); Assert.True(called); }
public void ConfigureHookLoggingWithNullFn() { MOCK_ConfigureHookLogging((int verbosity, ConfigureHookLoggingFnDelegate fn, IntPtr userarg) => { Assert.Null(fn); return((int)Yogi.ErrorCode.Ok); }); Yogi.ConfigureHookLogging(Yogi.Verbosity.Info, null); }
public void ConfigureHookLoggingError() { MOCK_ConfigureHookLogging((int verbosity, ConfigureHookLoggingFnDelegate fn_, IntPtr userarg) => { return((int)Yogi.ErrorCode.Unknown); }); Yogi.LogToHookFnDelegate fn = (Yogi.Verbosity severity, Yogi.Timestamp timestamp, int tid, string file, int line, string comp, string msg) => { }; Assert.ThrowsAny <Yogi.FailureException>(() => { Yogi.ConfigureHookLogging(Yogi.Verbosity.Info, fn); }); }