Beispiel #1
0
        public void Create_Associates_SetterIntercepter_With_Proxy()
        {
            var device       = DeviceProxy.Create <Dummy>();
            var type         = device.GetType();
            var interceptors = type.GetField("__interceptors").GetValue(device) as IInterceptor[];

            Assert.That(interceptors, Has.Length.EqualTo(1));
            Assert.That(interceptors[0], Is.InstanceOf <SetterInterceptor>());
        }
        public void Map6_Populates_Transitions()
        {
            var dummy = DeviceProxy.Create <Dummy>();

            Assert.That(dummy.Transitions, Contains.Key("six"));
            Assert.That(dummy.Transitions["six"], Is.Not.Null);

            var transitionValue = dummy.Transitions["six"];

            Assert.That(transitionValue.Handler, Is.Not.Null);
            Assert.That(transitionValue.Fields, Has.Length.EqualTo(6));
        }
        public void Map0_Populates_Transitions()
        {
            var dummy = DeviceProxy.Create <Dummy>();

            Assert.That(dummy.Transitions, Contains.Key("zero"));
            Assert.That(dummy.Transitions["zero"], Is.Not.Null);

            var transitionValue = dummy.Transitions["zero"];

            Assert.That(transitionValue.Handler, Is.Not.Null);
            Assert.That(transitionValue.Fields, Is.Null);
        }
        public async Task Publishes_SetPropertyCommand_On_Device_Property_Set()
        {
            var source = new TaskCompletionSource <bool>();
            var dummy  = DeviceProxy.Create <Dummy>();

            CommandBus.Instance.Subscribe <SetPropertyCommand>((command) => {
                var c = (SetPropertyCommand)command;

                Assert.That(c.PropertyName, Is.EqualTo("value"));
                Assert.That(c.PropertyValue, Is.EqualTo(3));

                source.SetResult(true);
            });

            dummy.Value = 3;

            await source.Task;
        }
        public async Task Save_Publishes_SaveCommand()
        {
            var source = new TaskCompletionSource <bool>();
            var dummy  = DeviceProxy.Create <Dummy>();

            dummy.Id = "1234";

            CommandBus.Instance.Subscribe <SaveCommand>((command) => {
                var c = (SaveCommand)command;

                Assert.That(c.DeviceId, Is.EqualTo("1234"));

                CommandBus.Instance.RemoveAllSubscriptions();
                source.SetResult(true);
            });

            await dummy.Save();

            await source.Task;
        }
Beispiel #6
0
        public void Create_Returns_Proxy()
        {
            var device = DeviceProxy.Create <Dummy>();

            Assert.That(ProxyUtil.IsProxy(device), Is.True);
        }
Beispiel #7
0
 public override T Create(Type objectType)
 {
     return(DeviceProxy.Create <T>());
 }