Example #1
0
        public async Task ShouldChangeText_InvalidRange_ThrowsArgumentOutOfRangeException()
        {
            var result = Helpers.RunOnUIThreadAsync(() =>
            {
                var textField = new UITextField();
                var filter    = new LengthFilter(0);

                var range = new NSRange(0, 1000);
                return(filter.ShouldChangeText(textField, "old", range, "new"));
            });

            await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => result);
        }
Example #2
0
        public async Task ShouldChangeText_UITextField_ReturnsExpected(
            string oldText,
            int insertPosition,
            string newText,
            int maxLength,
            bool expectedResult)
        {
            var result = await Helpers.RunOnUIThreadAsync(() =>
            {
                var textField = new UITextField();
                var range     = new NSRange(insertPosition, 0);
                var filter    = new LengthFilter(maxLength);

                return(filter.ShouldChangeText(textField, oldText, range, newText));
            });

            Assert.Equal(expectedResult, result);
        }
Example #3
0
        public async Task ShouldChangeText_UITextFieldWithCharacterOverwritingEnabled_ReturnsExpected(
            string oldText,
            int insertPosition,
            string newText,
            int maxLength,
            string expectedResult)
        {
            var result = await Helpers.RunOnUIThreadAsync(() =>
            {
                var textField = new UITextField {
                    Text = oldText
                };
                var range  = new NSRange(insertPosition, 0);
                var filter = new LengthFilter(maxLength);

                filter.IsCharacterOverwritingEnabled = true;
                filter.ShouldChangeText(textField, oldText, range, newText);

                return(textField.Text);
            });

            Assert.Equal(expectedResult, result);
        }