public async Task EmitLost()
        {
            if (!File.Exists("dbus-daemon"))
            {
                throw new SkipTestException("dbus-daemon not present");
            }
            using (var dbusDaemon = new DBusDaemon())
            {
                string serviceName = "tmds.dbus.test";

                await dbusDaemon.StartAsync();

                var address = dbusDaemon.Address;

                var conn1 = new Connection(address);
                await conn1.ConnectAsync();

                var onLost = new ObservableAction();
                await conn1.RegisterServiceAsync(serviceName, onLost.Action, ServiceRegistrationOptions.AllowReplacement);

                var conn2 = new Connection(address);
                await conn2.ConnectAsync();

                await conn2.RegisterServiceAsync(serviceName, ServiceRegistrationOptions.ReplaceExisting);

                await onLost.AssertNumberOfCallsAsync(1);
            }
        }
示例#2
0
        public async Task EmitAquired()
        {
            using (var dbusDaemon = new DBusDaemon())
            {
                string serviceName = "tmds.dbus.test";

                await dbusDaemon.StartAsync();

                var address = dbusDaemon.Address;

                var conn1 = new Connection(address);
                await conn1.ConnectAsync();

                var conn1OnLost    = new ObservableAction();
                var conn1OnAquired = new ObservableAction();
                await conn1.QueueServiceRegistrationAsync(serviceName, conn1OnAquired.Action, conn1OnLost.Action, ServiceRegistrationOptions.AllowReplacement);

                await conn1OnAquired.AssertNumberOfCallsAsync(1);

                await conn1OnLost.AssertNumberOfCallsAsync(0);

                var conn2 = new Connection(address);
                await conn2.ConnectAsync();

                var conn2OnLost    = new ObservableAction();
                var conn2OnAquired = new ObservableAction();
                await conn2.QueueServiceRegistrationAsync(serviceName, conn2OnAquired.Action, conn2OnLost.Action);

                await conn1OnAquired.AssertNumberOfCallsAsync(1);

                await conn1OnLost.AssertNumberOfCallsAsync(1);

                await conn2OnAquired.AssertNumberOfCallsAsync(1);

                await conn2OnLost.AssertNumberOfCallsAsync(0);
            }
        }