Ejemplo n.º 1
0
        public void DecimalFormula_FormulaValueIsSetFromXmlNodeInConstructor()
        {
            // Arrange
            LoadXmlTestData("A1", "decimal", "1.3");
            // Act
            var validation = new ExcelDataValidationDecimal(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);

            Assert.AreEqual(1.3D, validation.Formula.Value);
        }
Ejemplo n.º 2
0
        public void ListFormula_FormulasExcelFormulaIsSetFromXmlNodeInConstructor()
        {
            // Arrange
            LoadXmlTestData("A1", "list", "A1");
            // Act
            var validation = new ExcelDataValidationList(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.List, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual("A1", validation.Formula.ExcelFormula);
        }
Ejemplo n.º 3
0
        public void DataValidations_ShouldSetShowInputMessageFromExistingXml()
        {
            // Arrange
            LoadXmlTestData("A1", "whole", "1", false, true);
            // Act
            var validation = new ExcelDataValidationInt(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.IsTrue(validation.ShowInputMessage ?? false);
        }
Ejemplo n.º 4
0
        public void DataValidations_ShouldSetErrorTitleFromExistingXml()
        {
            // Arrange
            LoadXmlTestData("A1", "whole", "1", "Prompt", "PromptTitle", "Error", "ErrorTitle");
            // Act
            var validation = new ExcelDataValidationInt(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual("ErrorTitle", validation.ErrorTitle);
        }
Ejemplo n.º 5
0
        public void DataValidations_ShouldSetOperatorFromExistingXml()
        {
            // Arrange
            LoadXmlTestData("A1", "whole", "greaterThanOrEqual", "1");
            // Act
            var validation = new ExcelDataValidationInt(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual(ExcelDataValidationOperator.greaterThanOrEqual, validation.Operator);
        }
Ejemplo n.º 6
0
        public void UidShouldBeSetOnValidations()
        {
            // Arrange
            LoadXmlTestData("A1", "decimal", "1.3");
            var id = ExcelDataValidation.NewId();
            // Act
            var validation = new ExcelDataValidationDecimal(_sheet, id, "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual(id, validation.Uid);
        }
Ejemplo n.º 7
0
        public void CustomFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
        {
            // Arrange
            LoadXmlTestData("A1", "decimal", "A1");

            // Act
            var validation = new ExcelDataValidationCustom(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Custom, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual("A1", validation.Formula.ExcelFormula);
        }
Ejemplo n.º 8
0
        public void ListFormula_FormulaValueIsSetFromXmlNodeInConstructorOrderIsCorrect()
        {
            // Arrange
            LoadXmlTestData("A1", "list", "\"1,2\"");
            // Act
            var validation = new ExcelDataValidationList(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.List, _dataValidationNode, _namespaceManager);

            // Assert
            CollectionAssert.AreEquivalent(new List <string> {
                "1", "2"
            }, (ICollection)validation.Formula.Values);
        }
Ejemplo n.º 9
0
        public void TimeFormula_ValueIsSetFromConstructorValidateSecond()
        {
            // Arrange
            var time = new ExcelTime(0.812M);

            LoadXmlTestData("A1", "time", "0.812");

            // Act
            var formula = new ExcelDataValidationTime(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Time, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual(time.Second.Value, formula.Formula.Value.Second.Value);
        }
Ejemplo n.º 10
0
        public void DateTimeFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
        {
            // Arrange
            var date = DateTime.Parse("2011-01-08");

            LoadXmlTestData("A1", "decimal", "A1");

            // Act
            var validation = new ExcelDataValidationDateTime(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual("A1", validation.Formula.ExcelFormula);
        }
Ejemplo n.º 11
0
        public void DateTimeFormula_FormulaValueIsSetFromXmlNodeInConstructor()
        {
            // Arrange
            var date         = DateTime.Parse("2011-01-08");
            var dateAsString = date.ToOADate().ToString(_cultureInfo);

            LoadXmlTestData("A1", "decimal", dateAsString);
            // Act
            var validation = new ExcelDataValidationDateTime(_sheet, ExcelDataValidation.NewId(), "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);

            // Assert
            Assert.AreEqual(date, validation.Formula.Value);
        }