Exemple #1
0
        public void AttributeServiceCallShouldFindCorrectFunction()
        {
            // ARRANGE
            var app           = new AssmeblyDaemonApp();
            var netDaemonMock = new Mock <INetDaemon>();

            // ACT
            app.HandleAttributeInitialization(netDaemonMock.Object);

            // ASSERT
            var     expObject = new ExpandoObject();
            dynamic data      = expObject;

            data.method = "HandleServiceCall";
            data.@class = "AssmeblyDaemonApp";

            netDaemonMock.Verify(n => n.CallService("netdaemon", "register_service", expObject, false), Times.Once);
            netDaemonMock.Verify(n => n.ListenServiceCall("netdaemon", "AssmeblyDaemonApp_HandleServiceCall", It.IsAny <Func <dynamic?, Task> >()), Times.Once);
        }
        public async Task AttributeServiceCallShouldFindCorrectFunction()
        {
            // ARRANGE
            await InitializeFakeDaemon().ConfigureAwait(false);

            var app = new AssmeblyDaemonApp();

            app.Id = "id";


            DefaultDaemonHost.InternalRunningAppInstances[app.Id] = app;

            // ACT
            await app.HandleAttributeInitialization(DefaultDaemonHost).ConfigureAwait(false);

            await RunFakeDaemonUntilTimeout().ConfigureAwait(false);

            // ASSERT
            Assert.Single(app.DaemonCallBacksForServiceCalls);
        }