Exemplo n.º 1
0
        public void DataPicker_GetValueInOptionsWithStringOptions_ShouldReturnAValue_WhenReturnKeyIsPressed()
        {
            // Arrange
            var displayStub = new Mock <IPinpadDisplay>();

            displayStub.Setup(x => x.ShowMessage("label",
                                                 string.Empty,
                                                 DisplayPaddingType.Center))
            .Returns(true);

            var keyboardStub = new Mock <IPinpadKeyboard>();

            keyboardStub.Setup(x => x.GetKey())
            .Returns(PinpadKeyCode.Return);

            var dummyInfos = Mock.Of <IPinpadInfos>();

            IDataPicker picker = new DataPicker(
                keyboardStub.Object,
                dummyInfos,
                displayStub.Object);

            string[] options = { "Um", "Dois", "Tres", "Quatro", "Cinco" };

            // Act
            string readValue = picker.GetValueInOptions(
                label: "testLabel",
                circularBehavior: false,
                options: options);

            // Assert
            Assert.IsFalse(string.IsNullOrEmpty(readValue));
            Assert.AreEqual("Um", readValue);
        }
Exemplo n.º 2
0
        public void DataPicker_GetValueInOptionsWithShortOptions_ShouldReturnAValue_WhenReturnKeyIsPressed()
        {
            // Arrange
            var displayStub = new Mock <IPinpadDisplay>();

            displayStub.Setup(x => x.ShowMessage("label",
                                                 string.Empty,
                                                 DisplayPaddingType.Center))
            .Returns(true);

            var keyboardStub = new Mock <IPinpadKeyboard>();

            keyboardStub.Setup(x => x.GetKey())
            .Returns(PinpadKeyCode.Return);

            var dummyInfos = Mock.Of <IPinpadInfos>();

            IDataPicker picker = new DataPicker(
                keyboardStub.Object,
                dummyInfos,
                displayStub.Object);

            short[] options = { 1, 2, 3, 4, 5 };

            // Act
            Nullable <short> readValue = picker.GetValueInOptions(
                label: "testLabel",
                circularBehavior: false,
                options: options);

            // Assert
            Assert.IsNotNull(readValue);
            Assert.IsTrue(readValue.HasValue);
            Assert.AreEqual(1, readValue.Value);
        }
Exemplo n.º 3
0
        public void DataPicker_GetValueInOptions_ShouldThrowException_IfLabelIsNullAndPassingStringOptionsAsParameters()
        {
            // Assert
            Assert.Throws <ArgumentException>(() =>
            {
                // Arrange
                var dummyKeyboard = Mock.Of <IPinpadKeyboard>();
                var dummyInfos    = Mock.Of <IPinpadInfos>();
                var dummyDisplay  = Mock.Of <IPinpadDisplay>();

                IDataPicker picker = new DataPicker(
                    dummyKeyboard,
                    dummyInfos,
                    dummyDisplay);

                string[] options  = { "Um", "Dois", "Tres", "Quatro", "Cinco" };
                string emptyLabel = null;

                // Act
                picker.GetValueInOptions(
                    label: emptyLabel,
                    circularBehavior: false,
                    options: options);
            });
        }
Exemplo n.º 4
0
        public void DataPicker_GetValueInOptions_ShouldThrowException_IfOptionsAsShortAreNull()
        {
            // Assert
            Assert.Throws <ArgumentException>(() =>
            {
                // Arrange
                var displayStub = new Mock <IPinpadDisplay>();
                displayStub.Setup(x => x.ShowMessage("label",
                                                     string.Empty,
                                                     DisplayPaddingType.Center))
                .Returns(true);

                var keyboardStub = new Mock <IPinpadKeyboard>();
                keyboardStub.Setup(x => x.GetKey())
                .Returns(PinpadKeyCode.Cancel);

                var dummyInfos     = Mock.Of <IPinpadInfos>();
                IDataPicker picker = new DataPicker(keyboardStub.Object,
                                                    dummyInfos,
                                                    displayStub.Object);

                // Act
                Nullable <short> value = picker.GetValueInOptions(
                    label: "label",
                    circularBehavior: false,
                    options: new short[] { });
            });
        }
Exemplo n.º 5
0
        public void DataPicker_GetValueInOptions_ShouldThrowException_IfLabelIsEmptyAndPassingShortOptionsAsParameters()
        {
            // Assert
            Assert.Throws <ArgumentException>(() =>
            {
                // Arrange
                var dummyKeyboard = Mock.Of <IPinpadKeyboard>();
                var dummyInfos    = Mock.Of <IPinpadInfos>();
                var dummyDisplay  = Mock.Of <IPinpadDisplay>();

                IDataPicker picker = new DataPicker(
                    dummyKeyboard,
                    dummyInfos,
                    dummyDisplay);

                short[] options   = { 1, 2, 3, 4, 5, 6, 666 };
                string emptyLabel = string.Empty;

                // Act
                picker.GetValueInOptions(
                    label: emptyLabel,
                    circularBehavior: false,
                    options: options);
            });
        }