Пример #1
0
        public void GetValue_BooleanTests(string strValue, bool?expected)
        {
            //Given
            _cell.Setup(x => x.ToString()).Returns(strValue);

            //When
            var value = CellExtensions.GetValue(_cell.Object, new FieldConfig {
                Type = "boolean"
            });

            //Then
            value.Should().Be(expected);
        }
Пример #2
0
        public void GetValue_Numeric_WhenTypeIsNotNumeric_ReturnsValidNumeric(string strValue, double?expected)
        {
            //Given
            _cell.Setup(x => x.ToString()).Returns(strValue);
            _cell.SetupGet(x => x.CellType).Returns(CellType.String);

            //When
            var value = CellExtensions.GetValue(_cell.Object, new FieldConfig {
                Type = "numeric"
            });

            //Then
            value.Should().Be(expected);
        }
Пример #3
0
        public void GetValue_NumericTest(string strValue, double?expected)
        {
            //Givend
            _cell.Setup(x => x.ToString()).Returns(strValue);
            _cell.SetupGet(x => x.CellType).Returns(CellType.Numeric);
            _cell.SetupGet(x => x.NumericCellValue).Returns(expected.Value);

            //When
            var value = CellExtensions.GetValue(_cell.Object, new FieldConfig {
                Type = "numeric"
            });

            //Then
            value.Should().Be(expected);
        }
Пример #4
0
        public void GetValue_WhenDateFormatIsInvalid_ReturnsInvalidDate()
        {
            //Given
            _cell.Setup(x => x.ToString()).Returns("xxx");

            //When
            var value = CellExtensions.GetValue(_cell.Object, new FieldConfig
            {
                Type        = "date",
                Validations = new ValidationOptions {
                }
            });

            //Then
            value.Should().BeOfType(typeof(DateResult));
        }
Пример #5
0
        public void GetValue_DateTests(string strDate, string[] formats, DateResult expected)
        {
            //Given
            _cell.Setup(x => x.ToString()).Returns(strDate);

            //When
            var value = CellExtensions.GetValue(_cell.Object, new FieldConfig
            {
                Type        = "date",
                Validations = new ValidationOptions
                {
                    Formats = formats
                }
            });

            //Then
            value.Should().BeEquivalentTo(expected);
        }