public void TextPackageCorrectlyExtractedFromCompatibleElement(Type fieldType, string result) { var dragRec = new DragGestureRecognizer(); var element = (VisualElement)Activator.CreateInstance(fieldType); Assert.IsTrue(element.TrySetValue(result)); var args = dragRec.SendDragStarting((IView)element); Assert.AreEqual(result, args.Data.Text); }
public void DragStartingCommandFires() { var dragRec = new DragGestureRecognizer(); var parameter = new Object(); object commandExecuted = null; Command cmd = new Command(() => commandExecuted = parameter); dragRec.DragStartingCommand = cmd; dragRec.DragStartingCommandParameter = parameter; dragRec.SendDragStarting(new Label()); Assert.AreEqual(commandExecuted, parameter); }
public void DropCompletedCommandFiresOnce() { int counter = 0; var dragRec = new DragGestureRecognizer(); Command cmd = new Command(() => counter++); dragRec.SendDragStarting(new Label()); dragRec.DropCompletedCommand = cmd; dragRec.SendDropCompleted(new DropCompletedEventArgs()); dragRec.SendDropCompleted(new DropCompletedEventArgs()); dragRec.SendDropCompleted(new DropCompletedEventArgs()); Assert.AreEqual(1, counter); }
public void UserSpecifiedTextIsntOverwritten() { var dragRec = new DragGestureRecognizer(); var element = new Label() { Text = "WRONG TEXT" }; dragRec.DragStarting += (_, args) => { args.Data.Text = "Right Text"; }; var returnedArgs = dragRec.SendDragStarting(element); Assert.AreEqual("Right Text", returnedArgs.Data.Text); }
public void HandledTest() { string testString = "test String"; var dragRec = new DragGestureRecognizer(); var element = new Label() { Text = testString }; element.Text = "Text Shouldn't change"; var args = new DragStartingEventArgs(); args.Handled = true; args.Data.Text = "Text Shouldn't change"; dragRec.SendDragStarting(element); Assert.AreNotEqual(args.Data.Text, testString); }
public void UserSpecifiedImageIsntOverwritten() { var dragRec = new DragGestureRecognizer(); var element = new Image() { Source = "http://www.someimage.com" }; FileImageSource fileImageSource = new FileImageSource() { File = "yay.jpg" }; dragRec.DragStarting += (_, args) => { args.Data.Image = fileImageSource; }; var returnedArgs = dragRec.SendDragStarting(element); Assert.AreEqual(fileImageSource, returnedArgs.Data.Image); }