vendredi 5 juin 2015

Create Unit test for Xsockets

Hi Im trying to better understand how to use unit tests. I want to test Send and Receive in Xsockets with Nunit.

Right now when I run the test nothing is happening

I just want to create the listener and then call invoke, then wait and update the result value.

I want something like when you test an event Unit testing that an event is raised in C#

Xsockets C#

[Test]
    public  void Xsockets_Change_Test()
    {
        var mocks = new MockRepository();
        var metaData = mocks.CreateMock<MetaData>();
        var result = 0;

        controller.On<MetaData>("Change",
            (message) =>
            {
                result++;
            });

        controller.Invoke("Change", metaData);            
        Assert.That(result, Is.EqualTo(1));

    }

IListener On(string target, Action action);

void Invoke(string target, object data);

Thanks

Aucun commentaire:

Enregistrer un commentaire