public EventHandling(ITestOutputHelper output)
     : base(output)
 {
     this.mockWebsocketInterface = new MockWebsocketInterface();
     this.mockWebsocketInterface.Start();
     this.testMsbClient = new MsbClient(this.mockWebsocketInterface.URL);
 }
                public void NoResponseEventShouldBeSendForFunctionCall()
                {
                    var mockWebsocketInterface = new MockWebsocketInterface();

                    mockWebsocketInterface.Start();
                    var testMsbClient   = new MsbClient(mockWebsocketInterface.URL);
                    var testSmartObject = new SmartObject(Guid.NewGuid().ToString(), "Name", "Description", Guid.NewGuid().ToString());
                    var responseEventWhichShouldNotBeSend = new Event("ResponseEventWhichShouldNotBeSend", string.Empty, string.Empty, new DataFormat());

                    testSmartObject.AddEvent(responseEventWhichShouldNotBeSend);
                    var testFunction = new Function(this.GetType().GetRuntimeMethod("NoResponseEventShouldBeSendForFunctionCallMsbFunction", new Type[] { typeof(FunctionCallInfo) }), this);

                    testSmartObject.AddFunction(testFunction);

                    Assert.True(testMsbClient.ConnectAsync().Result);
                    Assert.True(testMsbClient.RegisterAsync(testSmartObject).Result);
                    string functionCallJson = $@"{MessageType.FUNCTION_CALLBACK} {{
                        ""uuid"" : ""{testSmartObject.Uuid}"",
                        ""correlationId"" : ""{Guid.NewGuid().ToString()}"",
                        ""functionId"" : ""NoResponseEventShouldBeSendForFunctionCallMsbFunction"",
                        ""functionParameters"" : {{ }}
                    }}";

                    try
                    {
                        var raisedEvent = Assert.RaisesAnyAsync <EventArgs>(
                            h => testMsbClient.EventPublished += h,
                            h => testMsbClient.EventPublished -= h,
                            () => Task.Run(() =>
                        {
                            mockWebsocketInterface.SendMessageOfType(functionCallJson);
                            Thread.Sleep(100);
                        })).Result;
                    }
                    catch (AggregateException e)
                    {
                        Assert.Contains("No event was raised", e.InnerException.Message);
                    }
                }
                public void PrimtiveFunctionParameterConversion_Integers()
                {
                    var mockWebsocketInterface = new MockWebsocketInterface();

                    mockWebsocketInterface.Start();
                    var testMsbClient   = new MsbClient(mockWebsocketInterface.URL);
                    var testSmartObject = new SmartObject(Guid.NewGuid().ToString(), "Name", "Description", Guid.NewGuid().ToString());
                    var testFunction    = new Function(this.GetType().GetRuntimeMethod("TestFunction", new Type[] { typeof(int), typeof(FunctionCallInfo) }), this);

                    testSmartObject.AddFunction(testFunction);

                    Assert.True(testMsbClient.ConnectAsync().Result);
                    Assert.True(testMsbClient.RegisterAsync(testSmartObject).Result);
                    string functionCallJson = $@"{MessageType.FUNCTION_CALLBACK} {{
                        ""uuid"" : ""{testSmartObject.Uuid}"",
                        ""correlationId"" : ""{Guid.NewGuid().ToString()}"",
                        ""functionId"" : ""TestFunction"",
                        ""functionParameters"" : {{
                            ""testParameter"" : 1234
                        }}
                    }}";

                    mockWebsocketInterface.SendMessageOfType(functionCallJson);
                    var maxPollTries = 10;

                    for (int i = 0; i < maxPollTries; i++)
                    {
                        if (this.testFunctionCallReceived)
                        {
                            break;
                        }
                        else
                        {
                            Thread.Sleep(50);
                        }
                    }

                    Assert.True(this.testFunctionCallReceived);
                }