コード例 #1
0
        public void Test_accessing_out_of_bound_element()
        {
            Tr.SetTypes(typeof(RowDefinitionCollection),
                        typeof(ColumnDefinitionCollection));

            var grid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(2)
                    }
                },

                RowDefinitions = new RowDefinitionCollection()
            };

            var page = new ContentPage
            {
                Content = grid
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetObjectRequest>(r =>
            {
                r.Path     = new [] { "ColumnDefinitions[1]" };
                r.WidgetId = grid.Id.ToString();
            });

            InspectorReaction.Register <GetObjectRequest, GetObjectReaction>(page);
            Reaction.Execute(ctx);
            Assert.IsNull(ctx.Response);
        }
コード例 #2
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var request = ctx.Get <GetWidgetEventsRequest>();

            if (request == null)
            {
                return;
            }

            var pair = Surface[request.WidgetId];

            var events = pair?
                         .VisualElement?
                         .GetType()
                         .GetPublicEvents()
                         .Select(UIEvent.Create)
                         .ToArray();

            if (events == null)
            {
                return;
            }

            ctx.SetResponse <GetWidgetEventsResponse>(r =>
            {
                r.Events   = events;
                r.WidgetId = request.WidgetId;
            });
        }
コード例 #3
0
        public void Should_respond_with_GridLength_type_with_two_constructors()
        {
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());
            Tr.SetTypes(typeof(GridLength));

            var page = new ContentPage();
            var ctx  = new UIMessageContext();

            var typeName = typeof(GridLength).FullName;

            ctx.SetRequest <GetConstructorsRequest>(req =>
            {
                req.TypeName = typeName;
            });

            InspectorReaction.Register <GetConstructorsRequest, GetConstructorsReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Get <GetConstructorsResponse>();

            Assert.IsNotNull(res.Type);
            Assert.AreEqual(typeName, res.Type.FullName);
            Assert.AreEqual(2, res.Type.Constructors.Length);

            foreach (var ctor in res.Type.Constructors)
            {
                foreach (var p in ctor.Parameters)
                {
                    Assert.IsNotEmpty(p.UIType.PossibleValues);
                    Assert.AreEqual(p.TypeName, p.UIType.FullName);
                }
            }
        }
コード例 #4
0
        public void Should_serialize_BindingContext()
        {
            var ctx = new UIMessageContext();

            var value = new MyBindingType
            {
                Value = "test123"
            };

            var label = new Label
            {
                BindingContext = value
            };

            var page = new ContentPage
            {
                Content = label
            };

            ctx.SetRequest <GetBindingContextRequest>(r =>
            {
                r.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetBindingContextRequest, GetBindingContextReaction>(page);
            Reaction.Execute(ctx);

            var res = ctx.Response as GetBindingContextResponse;

            Assert.IsNotNull(res);
            Assert.AreEqual("{\"Value\":\"test123\",\"Child\":null}", res.Data);
        }
コード例 #5
0
        public void Add_nongeneric_collection()
        {
            var grid = new Grid();
            var page = new ContentPage
            {
                Content = grid
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <EditCollectionRequest>(r =>
            {
                r.Type     = EditCollectionType.Add;
                r.Path     = new[] { "ColumnDefinitions" };
                r.WidgetId = grid.Id.ToString();
            });

            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());

            Assert.IsEmpty(grid.ColumnDefinitions);

            InspectorReaction.Register <EditCollectionRequest, EditCollectionReaction>(page);
            Reaction.Execute(ctx);

            Assert.IsNotEmpty(grid.ColumnDefinitions);

            var response = ctx.Get <EditCollectionResponse>();

            Assert.IsTrue(response.Successful);
            Assert.AreEqual(EditCollectionType.Add, response.Type);
        }
コード例 #6
0
        public void Should_return_property_types_and_names()
        {
            const string requestedType = "System.Guid";

            Tr.Types = new HashSet <UIType>(new[]
            {
                new UIType
                {
                    FullName = requestedType
                }
            });

            var label = new Label();
            var page  = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();
            var property = response?.Properties.FirstOrDefault(p => p.PropertyName.Equals("Id"));

            Assert.IsNotNull(property, "Id property should have been found.");
            Assert.AreEqual(property.UIType.FullName, typeof(Guid).FullName);
            Assert.IsNotNull(property.Value, "Value should have been set.");
        }
コード例 #7
0
        public void Attach_button_to_grid_and_not_set_row_and_col()
        {
            var grid = new Grid();
            var page = new ContentPage
            {
                Title   = "Testing create button action",
                Content = grid
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <CreateWidgetRequest>(r =>
            {
                r.ParentId = grid.Id.ToString();
                r.TypeName = "Xamarin.Forms.Button";
            });

            InspectorReaction.Register <CreateWidgetRequest, CreateWidgetReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <CreateWidgetResponse>();

            Assert.IsNotNull(response, "Response should not be null.");
            Assert.IsTrue(response.Parent.Type == nameof(Grid), "Expected type to be grid.");
            Assert.IsTrue(response.Widget.Type == nameof(Button), "Expected type to be button.");
            Assert.IsTrue(response.Parent.Children[0].Type == nameof(Button), "Expected child to be button.");
        }
コード例 #8
0
        public void Should_return_property_types_and_names()
        {
            Tr.SetTypes(typeof(Enum));

            var label = new Label();
            var page  = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = label.Id.ToString();
            });

            Dr.Add(typeof(Enum), new EnumGenerator());
            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();

            var property = response?.Properties.FirstOrDefault(p => p.PropertyName.Equals("HorizontalTextAlignment"));

            Assert.IsNotNull(property, "Property not found.");

            Assert.AreEqual(property.Value, TextAlignment.Start.ToString());
            Assert.AreEqual(property.UIType.Descriptor, UIPropertyDescriptors.Literals);

            // if this occurs, types will not be selected correctly by the client
            Assert.IsFalse(property.UIType.Descriptor.HasFlag(UIPropertyDescriptors.ValueType));
            CollectionAssert.IsNotEmpty(property.UIType.PossibleValues);
        }
コード例 #9
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var req = ctx.Get <CreateGridRequest>();

            if (req == null)
            {
                return;
            }

            var target = Surface[req.ParentId];

            if (target == null)
            {
                return;
            }

            var attached      = false;
            var rowCollection = new RowDefinitionCollection();
            var colCollection = new ColumnDefinitionCollection();

            for (var i = 0; i < req.Rows; i++)
            {
                var row = new RowDefinition();
                rowCollection.Add(row);
            }

            for (var j = 0; j < req.Columns; j++)
            {
                var col = new ColumnDefinition();
                colCollection.Add(col);
            }

            var view = new Grid
            {
                RowDefinitions    = rowCollection,
                ColumnDefinitions = colCollection,
                ColumnSpacing     = req.ColumnSpacing,
                RowSpacing        = req.RowSpacing
            };

            Thread.Invoke(() =>
            {
                attached = Surface.SetParent(view, target);
            });

            if (!attached)
            {
                return;
            }

            var pair = Surface[view.Id];

            ctx.SetResponse <CreateWidgetResponse>(res =>
            {
                res.Widget = pair.UIWidget;
                res.Parent = target.UIWidget;
                res.Suggest <GetVisualTreeRequest>();
            });
        }
コード例 #10
0
        public void Should_create_null_objects_when_default_ctor_called()
        {
            // Code relies on this behavior.
            var ctx = new UIMessageContext();

            Assert.IsNull(ctx.Request, "Request expected to be null.");
            Assert.IsNull(ctx.Response, "Response expected to be null.");
        }
コード例 #11
0
        public void Should_not_return_value_for_UserObjects()
        {
            Tr.Types = new HashSet <UIType>(new[]
            {
                new UIType
                {
                    FullName = "System.String",
                },
                new UIType
                {
                    FullName = "System.Boolean"
                },
                new UIType
                {
                    FullName = "Xamarin.Forms.Rectangle"
                },
                new UIType
                {
                    FullName = "Xamarin.Forms.Font"
                }
            });

            var label = new Label
            {
                Text = "My Label"
            };

            var page = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();
            var pBounds  = response.Properties.First(p => p.PropertyName == "Bounds");

            Assert.IsNull(pBounds.Value);
            Assert.IsTrue(pBounds.UIType.Descriptor == UIPropertyDescriptors.ValueType);

            var pFont = response.Properties.First(p => p.PropertyName == "Font");

            Assert.IsNull(pFont.Value);
            Assert.IsTrue(pFont.UIType.Descriptor == UIPropertyDescriptors.ValueType);

            var pLabel = response.Properties.FirstOrDefault(p => p.PropertyName == "Text");

            Assert.IsNotNull(pLabel?.Value);
            Assert.IsTrue(pLabel.UIType.Descriptor != UIPropertyDescriptors.ValueType);
        }
コード例 #12
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            ctx.SetResponse <FakeQueueResponse>(r =>
            {
                r.Completed = true;
            });

            Context = ctx;
        }
コード例 #13
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            _req = ctx.Get <SetPropertyRequest>();
            if (_req == null)
            {
                return;
            }

            SetPropertyValue(_req.WidgetId, _req.Path, _req.Value, _req.IsBase64, _req.IsAttachedProperty);
        }
コード例 #14
0
        public void Suggest()
        {
            var ctx = new UIMessageContext();

            var res = ctx.SetResponse <OkResponse>(r =>
            {
                r.Suggest <GetVisualTreeRequest>();
            });

            Assert.AreEqual(res.NextSuggestedMessage, nameof(GetVisualTreeRequest));
        }
コード例 #15
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var request = ctx.Get <SupportedTypesRequest>();

            if (request == null)
            {
                return;
            }

            TypeRegistrar.Instance.Types = new HashSet <UIType>(request.Types);
        }
コード例 #16
0
ファイル: Reaction.cs プロジェクト: wiadiaang/uisleuth
        /// <summary>
        /// Execute a <see cref="Reaction"/> with the given <paramref name="context"/>.
        /// </summary>
        /// <param name="reaction">A <see cref="Reaction"/> object.</param>
        /// <param name="context">An object containing a request and response.</param>
        /// <returns>
        /// Returns true when a <see cref="Reaction"/> has been executed; otherwise, false.
        /// </returns>
        public static bool Execute(Reaction reaction, UIMessageContext context)
        {
            if (reaction == null)
            {
                throw new ArgumentNullException(nameof(reaction));
            }

            InspectorContainer.Current.BuildUp(reaction);
            reaction.OnExecute(context);
            return(true);
        }
コード例 #17
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var request = ctx.Get <CreateStackLayoutRequest>();

            if (request == null)
            {
                return;
            }

            var orientation = StackOrientation.Vertical;

            if (string.IsNullOrWhiteSpace(request.Orientation) || request.Orientation.ToLower() == "vertical")
            {
                orientation = StackOrientation.Vertical;
            }
            else if (request.Orientation.ToLower() == "horizontal")
            {
                orientation = StackOrientation.Horizontal;
            }

            var view = new StackLayout
            {
                Orientation = orientation,
                Spacing     = request.Spacing
            };

            var target = Surface[request.ParentId];

            if (target == null)
            {
                return;
            }

            var attached = false;

            Thread.Invoke(() =>
            {
                attached = Surface.SetParent(view, target);
            });

            if (!attached)
            {
                return;
            }

            var pair = Surface[view.Id];

            ctx.SetResponse <CreateWidgetResponse>(r =>
            {
                r.Widget = pair.UIWidget;
                r.Parent = target.UIWidget;
                r.Suggest <GetVisualTreeRequest>();
            });
        }
コード例 #18
0
        public void Null_collections()
        {
            Tr.SetTypes(typeof(IEnumerable <object>), typeof(ICollection <string>), typeof(IList <int>));

            var view = new NullCollectionView
            {
                Enumerable = null,
                Collection = null,
                List       = null
            };

            var page = new ContentPage
            {
                Content = view
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = view.Id.ToString();
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();

            foreach (var p in response.Properties)
            {
                var d = p.UIType.Descriptor;

                if (p.PropertyName == "Enumerable")
                {
                    Assert.AreEqual(d, UIPropertyDescriptors.Enumerable);
                }

                if (p.PropertyName == "Collection")
                {
                    Assert.AreEqual(d, UIPropertyDescriptors.Enumerable | UIPropertyDescriptors.Collection);
                }

                if (p.PropertyName == "List")
                {
                    Assert.AreEqual(d, UIPropertyDescriptors.Enumerable
                                    | UIPropertyDescriptors.Collection
                                    | UIPropertyDescriptors.List);
                }

                Assert.IsNull(p.UIType.PossibleValues);
            }
        }
コード例 #19
0
ファイル: TestReactions.cs プロジェクト: wiadiaang/uisleuth
        public void Execution_of_Register_with_lambda_passed_and_success()
        {
            var request = UIMessage.Create <FakeSimpleRequest>();
            var ctx     = new UIMessageContext {
                Request = request
            };

            Reaction.Register <FakeSimpleRequest, FakeTrackRequestReaction>(() => new FakeTrackRequestReaction("Hello!"));
            var handled = Reaction.Execute(ctx);

            Assert.IsTrue(handled, "The OnExecute method should have returned true.");
            Assert.AreEqual(ctx.Message, "Hello!", "Data did not flow through the context.");
        }
コード例 #20
0
ファイル: TestReactions.cs プロジェクト: wiadiaang/uisleuth
        public void Test_execute_called_and_no_action_found()
        {
            // Note how FakeCompletedRequest and FakeSimpleRequest are different types
            Reaction.Register <FakeSimpleRequest, FakeAttachReaction>();
            var request = UIMessage.Create <FakeCompletedRequest>();
            var ctx     = new UIMessageContext {
                Request = request
            };

            var handled = Reaction.Execute(ctx);

            Assert.IsFalse(handled);
        }
コード例 #21
0
        public void Should_return_collection_values()
        {
            Dr.Add(typeof(ValueType), new StaticGenerator());
            Dr.Add(typeof(Enum), new EnumGenerator());

            Tr.SetTypes(typeof(GridLength),
                        typeof(RowDefinitionCollection),
                        typeof(ColumnDefinitionCollection));

            var grid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = new GridLength(2)
                    }
                },

                RowDefinitions = new RowDefinitionCollection()
            };

            var page = new ContentPage
            {
                Content = grid
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetObjectRequest>(r =>
            {
                r.Path     = new[] { "ColumnDefinitions[0]" };
                r.WidgetId = grid.Id.ToString();
            });

            InspectorReaction.Register <GetObjectRequest, GetObjectReaction>(page);
            Reaction.Execute(ctx);

            var resp = ctx.Get <ObjectResponse>();
            var val  = resp.Property.Value as ICollection <UIProperty>;

            Assert.AreEqual(0, resp.Property.ItemIndex);
            CollectionAssert.IsNotEmpty(val);

            var v = val?.ElementAt(0);

            // ReSharper disable once PossibleNullReferenceException
            Assert.IsNull(v.Value);
            Assert.AreEqual("Width", v.PropertyName);
            Assert.AreEqual("ColumnDefinitions[0]", v.Path[0]);
            Assert.AreEqual("Width", v.Path[1]);
        }
コード例 #22
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var request = ctx.Get <CreateWidgetRequest>();

            if (request == null)
            {
                return;
            }

            var viewType = TypeFinder.Find(request.TypeName);

            if (viewType == null)
            {
                return;
            }

            var view = Activator.CreateInstance(viewType) as View;

            if (view == null)
            {
                return;
            }

            var target = Surface[request.ParentId];

            if (target == null)
            {
                return;
            }

            var attached = false;

            Thread.Invoke(() =>
            {
                attached = Surface.SetParent(view, target);
            });

            if (!attached)
            {
                return;
            }

            var pair = Surface[view.Id];

            ctx.SetResponse <CreateWidgetResponse>(r =>
            {
                r.Widget = pair.UIWidget;
                r.Parent = target.UIWidget;
                r.Suggest <GetVisualTreeRequest>();
            });
        }
コード例 #23
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            if (ctx.Request == null)
            {
                return;
            }

            var req = ctx.Get <GetConstructorsRequest>();

            if (req == null)
            {
                return;
            }

            var type = TypeFinder.Find(req.TypeName);

            if (type == null)
            {
                return;
            }

            var ctors = UIConstructorMethods.GetConstructors(type);

            foreach (var ctor in ctors)
            {
                foreach (var p in ctor.Parameters)
                {
                    var pType = TypeFinder.Find(p.TypeName);

                    p.UIType = new UIType
                    {
                        Descriptor = Descriptor.GetDescriptors(pType),
                        FullName   = pType.FullName,
                    };

                    Descriptor.SetPossibleValues(pType, p.UIType);
                }
            }

            ctx.SetResponse <GetConstructorsResponse>(res =>
            {
                var descs = Descriptor.GetDescriptors(type);

                res.Type = new UIType
                {
                    FullName     = req.TypeName,
                    Descriptor   = descs,
                    Constructors = ctors
                };
            });
        }
コード例 #24
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var req = ctx.Get <DesktopReady>();

            if (req == null)
            {
                return;
            }

            ctx.SetResponse <MobileReady>(res =>
            {
                // ignored
            });
        }
コード例 #25
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            if (ctx.Request == null)
            {
                return;
            }

            var req = ctx.Get <GetObjectRequest>();

            if (req == null)
            {
                return;
            }

            var props = GetUIProperties(req.WidgetId, true, req.Path);

            if (!props.Any())
            {
                return;
            }

            var prop = props[0];

            if (prop.UIType.Descriptor.HasFlag(UIPropertyDescriptors.Enumerable))
            {
                if (prop.UIType.Descriptor.HasFlag(UIPropertyDescriptors.Enumerable))
                {
                    // grab index value; if null, return without creating an ObjectResponse.
                    var index = ReflectionMethods.GetIndexerValue(req.Path[0]);
                    if (index == null)
                    {
                        return;
                    }

                    var item = ReflectionMethods.GetItem(prop.Value, index.Value);
                    prop.Value = GetUIProperties(item);
                }
            }

            prop.Path = req.Path?.Union(prop.Path)?.ToArray();
            var cantCast = SetPath(prop.Value, req.Path);

            ctx.SetResponse <ObjectResponse>(res =>
            {
                res.UnknownCondition = cantCast;
                res.Property         = prop;
                res.WidgetId         = req.WidgetId;
                res.ObjectName       = UIProperty.GetLastPath(req.Path);
            });
        }
コード例 #26
0
        public void Should_mark_getter_properties_only_as_readonly()
        {
            Tr.Types = new HashSet <UIType>(new[]
            {
                new UIType
                {
                    Descriptor = UIPropertyDescriptors.None,
                    FullName   = "System.String",
                },
                new UIType
                {
                    Descriptor = UIPropertyDescriptors.None,
                    FullName   = "System.Boolean"
                },
                new UIType
                {
                    Descriptor = UIPropertyDescriptors.None,
                    FullName   = "Xamarin.Forms.Rectangle"
                }
            });

            var label = new Label
            {
                Text = "My Label"
            };

            var page = new ContentPage
            {
                Content = label
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = label.Id.ToString();
            });

            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();

            Assert.IsTrue(response.Properties.Any(), "Expected properties.");

            var focused = response.Properties.FirstOrDefault(p => p.PropertyName == "IsFocused");

            Assert.IsFalse(focused?.CanWrite, "IsFocus is readonly");
        }
コード例 #27
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            if (ctx.Request == null)
            {
                return;
            }

            var req = ctx.Get <GetWidgetPropertiesRequest>();

            if (string.IsNullOrWhiteSpace(req?.WidgetId))
            {
                return;
            }

            var props = GetUIProperties(req.WidgetId, req.IncludeValues) ?? new UIProperty[] { };

            foreach (var prop in props)
            {
                var isource = prop.Value as UIImageSource;
                if (isource != null)
                {
                    prop.Value = isource.FileName;
                    continue;
                }

                var wvsource = prop.Value as UrlWebViewSource;
                if (wvsource != null)
                {
                    prop.Value = wvsource.Url;
                    continue;
                }

                var hvsource = prop.Value as HtmlWebViewSource;
                if (hvsource != null)
                {
                    prop.Value = hvsource.Html;
                    continue;
                }
            }

            var pair = Surface[req.WidgetId];

            ctx.SetResponse <GetWidgetPropertiesResponse>(res =>
            {
                res.Widget     = pair.UIWidget;
                res.Properties = props;
            });
        }
コード例 #28
0
        public void Should_filter_unsupported_types()
        {
            const string requestedType = "System.String";

            Tr.Types = new HashSet <UIType>(new[]
            {
                new UIType
                {
                    Descriptor = UIPropertyDescriptors.None,
                    FullName   = requestedType
                }
            });

            var entry = new Entry();
            var page  = new ContentPage
            {
                Content = entry
            };

            var ctx = new UIMessageContext();

            ctx.SetRequest <GetWidgetPropertiesRequest>(r =>
            {
                r.WidgetId = entry.Id.ToString();
            });


            InspectorReaction.Register <GetWidgetPropertiesRequest, GetWidgetPropertiesReaction>(page);
            Reaction.Execute(ctx);

            var response = ctx.Get <GetWidgetPropertiesResponse>();

            Assert.IsNotNull(response, "Response should not be null.");
            Assert.IsNotNull(response.Widget, "Widget should not be null.");

            if (response.Properties != null)
            {
                foreach (var property in response.Properties)
                {
                    if (!property.UIType.FullName.Equals(requestedType, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Assert.Fail($"Expected {requestedType}, but {property.UIType.FullName} was returned.");
                    }
                }

                Assert.IsNotNull(response.Properties.First(p => p.PropertyName == "Text"), "The text property was not found.");
            }
        }
コード例 #29
0
        protected override void OnExecute(UIMessageContext ctx)
        {
            var request = ctx.Get <GestureRequest>();

            if (request == null)
            {
                return;
            }

            var toucher = InspectorContainer.Current.Resolve <ITouchEvent>();

            Thread.Invoke(() =>
            {
                toucher.Gesture(request.Path, request.Duration);
            });
        }
コード例 #30
0
        public void Get_methods()
        {
            var ctx = new UIMessageContext
            {
                Request  = new ServerStoppedOk(),
                Response = new OkResponse()
            };

            var req = ctx.Get <ServerStoppedOk>();

            Assert.AreEqual(ctx.Request, req, "Request check failed.");

            var res = ctx.Get <OkResponse>();

            Assert.AreEqual(ctx.Response, res, "Response check failed.");
        }