-
Notifications
You must be signed in to change notification settings - Fork 100
Communication debugging & testing
Daniel Frantík edited this page May 13, 2026
·
3 revisions
Add the tik4net.testing NuGet package to your test project and use TikFakeConnection instead
of a real ITikConnection. It intercepts at CallCommandSync so the full call stack — including
the O/R mapper — runs through real code.
-
Testing low-level API —
CallCommandSync, raw sentences -
Testing mid-level API —
ITikCommand.ExecuteList,ExecuteScalar,ExecuteAsync, … -
Testing high-level API —
LoadAll,Save,Delete,SaveListDifferences, …
Quick example:
var conn = new TikFakeConnection()
.WithEntities(new IpAddress { Id = "*1", Address = "10.0.0.1/24", Interface = "ether1" })
.WithScalarResponse(rows => rows.First() == "/ip/address/add", "*2")
.WithNonQuery(rows => rows.First() == "/ip/address/set");
var list = conn.LoadAll<IpAddress>();
Assert.AreEqual(1, list.Count());Since v 3.5 - complete communication is written to the Output window.
If you want to see what is going to the router or see router response, you can hook OnWriteRow and OnReadRow on ITikConnection object.
// ....
Connection.OnWriteRow += Connection_OnWriteRow;
// ....
private void Connection_OnWriteRow(object sender, TikConnectionCommCallbackEventArgs e)
{
Console.WriteLine(e.Word);
}If you are not sure about API syntax and you want to test it, you can use sample project SampleConsole to test your commands and see response.