示例#1
0
        public void AddObjectsTest()
        {
            var v1 = (NSString)"1";
            var v2 = (NSString)"2";

            using (var st = new NSMutableSet <NSString> ()) {
                Assert.Throws <ArgumentNullException> (() => st.AddObjects((NSString)null), "AddObjects ANE 1");
                Assert.Throws <ArgumentNullException> (() => st.AddObjects((NSString[])null), "AddObjects ANE 2");

                st.AddObjects(v1);
                Assert.AreEqual((nuint)1, st.Count, "AddObjects 1 Count");
                Assert.IsTrue(st.Contains(v1), "AddObjects 1 Contains");

                st.RemoveAll();
                st.AddObjects(v1, v1);
                Assert.AreEqual((nuint)1, st.Count, "AddObjects 2 Count");
                Assert.IsTrue(st.Contains(v1), "AddObjects 2 Contains");

                st.RemoveAll();
                st.AddObjects(v2, v1);
                Assert.AreEqual((nuint)2, st.Count, "AddObjects 3 Count");
                Assert.IsTrue(st.Contains(v1), "AddObjects 3 Contains a");
                Assert.IsTrue(st.Contains(v2), "AddObjects 3 Contains b");
            }
        }
示例#2
0
        public void ContainsTest()
        {
            var v1 = (NSString)"1";
            var v2 = (NSString)"2";

            using (var st = new NSMutableSet <NSString> (v1)) {
                Assert.Throws <ArgumentNullException> (() => st.Contains((NSString)null), "Contains ANE 1");
                Assert.IsTrue(st.Contains(v1), "Contains 1");
                Assert.IsFalse(st.Contains(v2), "Contains 2");
            }
        }
示例#3
0
        public void AddTest()
        {
            var v1 = (NSString)"1";

            using (var st = new NSMutableSet <NSString> ()) {
                Assert.Throws <ArgumentNullException> (() => st.Add((NSString)null), "Add ANE 1");

                st.Add(v1);
                Assert.IsTrue(st.Contains(v1), "Add 1");
                Assert.AreSame(v1, st.AnyObject, "Add 2");
            }
        }
示例#4
0
        public void RemoveTest()
        {
            var v1 = (NSString)"1";
            var v2 = (NSString)"2";

            using (var st = new NSMutableSet <NSString> (v1)) {
                Assert.Throws <ArgumentNullException> (() => st.Remove((NSString)null), "Remove ANE 1");

                st.Remove(v2);
                Assert.AreEqual((nuint)1, st.Count, "Remove 1 Count");
                Assert.IsTrue(st.Contains(v1), "Remove 1 Contains");
                Assert.AreSame(v1, st.AnyObject, "Remove 1 AnyObject");

                st.Remove(v1);
                Assert.AreEqual((nuint)0, st.Count, "Remove 2 Count");
            }
        }
示例#5
0
        private void handleUITouch(UITouch touch, UIEvent evt)
        {
            var location = touch.LocationInView(null);

            PendingInputs.Enqueue(new MousePositionAbsoluteInput {
                Position = new Vector2((float)location.X * view.Scale, (float)location.Y * view.Scale)
            });

            switch (touch.Phase)
            {
            case UITouchPhase.Moved:
            case UITouchPhase.Began:
                if (rightClickSupport && evt.ButtonMask == UIEventButtonMask.Secondary)
                {
                    pendingRightClickTouches.Add(touch);
                    PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Right, true));
                }
                else
                {
                    PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Left, true));
                }

                break;

            case UITouchPhase.Cancelled:
            case UITouchPhase.Ended:
                if (pendingRightClickTouches.Contains(touch))
                {
                    pendingRightClickTouches.Remove(touch);
                    PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Right, false));
                }
                else
                {
                    PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Left, false));
                }
                break;
            }
        }