func TestEventUsingWith(t *testing.T) {
	for _, l := range eventTestTbl {
		runTest(t, func(s *res.Service) {
			s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() }))
		}, func(s *restest.Session) {
			restest.AssertNoError(t, s.Service().With("test.model", func(r res.Resource) {
				r.Event(l.Event, l.Payload)
			}))
			s.GetMsg().
				AssertCustomEvent("test.model", l.Event, l.Payload)
		})
	}
}
Test method Event sends a custom event on the resource, using With.
package test
import (
	"encoding/json"
	"testing"
	res "github.com/jirenius/go-res"
	"github.com/jirenius/go-res/restest"
)
var eventTestTbl = []struct {
	Event   string
	Payload json.RawMessage
}{
	{"foo", json.RawMessage(`{"bar":42}`)},
	{"foo", json.RawMessage(`{"bar":42,"baz":null}`)},
	{"foo", json.RawMessage(`["bar",42]`)},
	{"foo", json.RawMessage(`"bar"`)},
	{"foo", json.RawMessage(`null`)},
	{"foo", nil},
	{"_foo_", json.RawMessage(`{"bar":42}`)},
	{"12", json.RawMessage(`{"bar":42}`)},
	{"<_!", json.RawMessage(`{"bar":42}`)},
}
var changeEventTestTbl = []struct {
	Payload map[string]interface{}
}{
	{map[string]interface{}{"foo": 42}},
	{map[string]interface{}{"foo": "bar"}},
	{map[string]interface{}{"foo": nil}},
	{map[string]interface{}{"foo": 12, "bar": true}},
	{map[string]interface{}{"foo": "bar", "deleted": res.DeleteAction}},
	{map[string]interface{}{"foo": res.Ref("test.model.bar")}},
	{map[string]interface{}{"foo": res.SoftRef("test.model.bar")}},
}
var addEventTestTbl = []struct {
	Value    interface{}
	Idx      int
	Expected json.RawMessage
}{
	{42, 0, json.RawMessage(`{"value":42,"idx":0}`)},
	{"bar", 1, json.RawMessage(`{"value":"bar","idx":1}`)},
	{nil, 2, json.RawMessage(`{"value":null,"idx":2}`)},
	{true, 3, json.RawMessage(`{"value":true,"idx":3}`)},
	{res.Ref("test.model.bar"), 4, json.RawMessage(`{"value":{"rid":"test.model.bar"},"idx":4}`)},
	{res.SoftRef("test.model.bar"), 5, json.RawMessage(`{"value":{"rid":"test.model.bar","soft":true},"idx":5}`)},
}
var removeEventTestTbl = []struct {
	Idx      int
	Expected json.RawMessage
}{
	{0, json.RawMessage(`{"idx":0}`)},
	{1, json.RawMessage(`{"idx":1}`)},
	{2, json.RawMessage(`{"idx":2}`)},
}
func TestEvent(t *testing.T) {
	for _, l := range eventTestTbl {
		runTest(t, func(s *res.Service) {
			s.Handle("model", res.Call("method", func(r res.CallRequest) {
				r.Event(l.Event, l.Payload)
				r.OK(nil)
			}))
		}, func(s *restest.Session) {
			req := s.Call("test.model", "method", nil)
			s.GetMsg().
				AssertCustomEvent("test.model", l.Event, l.Payload)
			req.Response()
		})
	}
}