Ejemplo n.º 1
0
        public void Init()
        {
            var valueFormatGerman = new ValueFormatMutable
            {
                DataType         = DataType.DateTime,
                DateFormat       = @"dd/MM/yyyy",
                DateSeparator    = ".",
                DecimalSeparator = ",",
                False            = @"Falsch",
                GroupSeparator   = ".",
                NumberFormat     = "0.##",
                TimeSeparator    = ":",
                True             = @"Wahr"
            };

            var ff  = new CsvFile();
            var col = new Column("StartDate", valueFormatGerman)
            {
                Ignore = true
            };

            ff.ColumnCollection.AddIfNew(col);
            Assert.AreEqual("StartDate", col.Name, "Name");
            Assert.AreEqual(DataType.DateTime, col.ValueFormatMutable.DataType, "DataType");
            Assert.IsTrue(col.Convert, "Convert");
            Assert.IsTrue(col.Ignore, "Ignore");
        }
Ejemplo n.º 2
0
        public void ValueFormatEquals()
        {
            var target  = new ValueFormatMutable();
            var target2 = new ValueFormatMutable();

            Assert.IsTrue(target2.Equals(target));
        }
Ejemplo n.º 3
0
        public void Ctor2()
        {
            var test2 = new ValueFormatMutable()
            {
                DataType = DataType.Integer
            };

            Assert.AreEqual(DataType.Integer, test2.DataType);
        }
Ejemplo n.º 4
0
        public void GetFormatDescriptionTest()
        {
            var a = new ValueFormatMutable {
                DataType = DataType.String
            };

            Assert.IsTrue(string.IsNullOrEmpty(a.GetFormatDescription()));
            var b = new ValueFormatMutable {
                DataType = DataType.DateTime
            };

            Assert.IsTrue(b.GetFormatDescription().Contains("MM/dd/yyyy"));
        }
Ejemplo n.º 5
0
        public void DecimalSeparator()
        {
            var a = new ValueFormatMutable {
                DataType = DataType.Numeric
            };

            a.GroupSeparator   = ".";
            a.DecimalSeparator = ",";
            Assert.AreEqual(",", a.DecimalSeparator);
            a.DecimalSeparator = ".";
            Assert.AreEqual(".", a.DecimalSeparator);
            Assert.AreEqual("", a.GroupSeparator);
        }
Ejemplo n.º 6
0
        public void ValueFormatCopyFrom()
        {
            var test1 = new ImmutableValueFormat(DataType.Double, groupSeparator: ".", decimalSeparator: ",");
            var test2 = new ValueFormatMutable()
            {
                DataType = DataType.Boolean
            };

            test2.CopyFrom(test1);
            Assert.AreEqual(DataType.Double, test2.DataType);
            Assert.AreEqual(",", test2.DecimalSeparator);
            Assert.AreEqual(".", test2.GroupSeparator);
        }
Ejemplo n.º 7
0
        public void ValueFormatCheckDefaults()
        {
            var test = new ValueFormatMutable();

            Assert.AreEqual(test.DateFormat, "MM/dd/yyyy", "DateFormat");
            Assert.AreEqual(test.DateSeparator, "/", "DateSeparator");
            Assert.AreEqual(test.DecimalSeparator, ".", "DecimalSeparator");
            Assert.AreEqual(test.False, "False", "False");
            Assert.AreEqual(test.GroupSeparator, string.Empty, "GroupSeparator");
            Assert.AreEqual(test.NumberFormat, "0.#####", "NumberFormat");
            Assert.AreEqual(test.TimeSeparator, ":", "TimeSeparator");
            Assert.AreEqual(test.True, "True", "True");
        }
Ejemplo n.º 8
0
        public void NotifyPropertyChangedTest()
        {
            var a = new ValueFormatMutable {
                DataType = DataType.DateTime
            };

            var fired = false;

            a.PropertyChanged += delegate { fired = true; };
            Assert.IsFalse(fired);
            a.DataType = DataType.Integer;
            Assert.IsTrue(fired);
        }
Ejemplo n.º 9
0
        public void GetTypeAndFormatDescriptionTest()
        {
            var a = new ValueFormatMutable {
                DataType = DataType.String
            };

            Assert.AreEqual("Text", a.GetTypeAndFormatDescription());
            var b = new ValueFormatMutable {
                DataType = DataType.DateTime
            };

            Assert.IsTrue(b.GetTypeAndFormatDescription().Contains("Date Time"));
            Assert.IsTrue(b.GetTypeAndFormatDescription().Contains("MM/dd/yyyy"));
        }
Ejemplo n.º 10
0
        public void ColumnGetDataType()
        {
            var test = new ValueFormatMutable();

            Assert.IsInstanceOfType(string.Empty, test.DataType.GetNetType());
            test.DataType = DataType.DateTime;
            Assert.IsInstanceOfType(DateTime.Now, test.DataType.GetNetType());
            test.DataType = DataType.Boolean;
            Assert.IsInstanceOfType(false, test.DataType.GetNetType());
            test.DataType = DataType.Double;
            Assert.IsInstanceOfType(double.MinValue, test.DataType.GetNetType());
            test.DataType = DataType.Numeric;
            Assert.IsInstanceOfType(decimal.MaxValue, test.DataType.GetNetType());
        }
Ejemplo n.º 11
0
        public void ValueFormatCopyFrom2()
        {
            var target = new ValueFormatMutable();

            target.CopyFrom(m_ValueFormatMutableGerman);

            Assert.AreEqual(target.DateFormat, "dd/MM/yyyy");
            Assert.AreEqual(target.DateSeparator, ".");
            Assert.AreEqual(target.DecimalSeparator, ",");
            Assert.AreEqual(target.False, "Falsch");
            Assert.AreEqual(target.GroupSeparator, ".");
            Assert.AreEqual(target.NumberFormat, "0.##");
            Assert.AreEqual(target.TimeSeparator, "-");
            Assert.AreEqual(target.True, "Wahr");
        }
Ejemplo n.º 12
0
        public void FormColumnUI_DateTime()
        {
            var col = new Column("MyTest", DataType.DateTime)
            {
                DateFormat = "dd/MM/yyyy", DateSeparator = ".", TimeSeparator = ":"
            };

            var df = new ValueFormatMutable()
            {
                DataType = DataType.DateTime, DateFormat = "dd/MMM/yyy", DateSeparator = "-", TimeSeparator = "#"
            };

            using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle))
                UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.UpdateDateLabel(df, true, "HH:mm", "[UTC]"));

            using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle))
                UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.UpdateDateLabel(df, false, "HH:mm:ss", "OtherColumn"));

            using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle))
                UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.AddDateFormat("dd MMM yy HH:mm tt"));
        }
Ejemplo n.º 13
0
        public void IsMatching()
        {
            var expected = new ValueFormatMutable();
            var current  = new ValueFormatMutable();

            foreach (DataType item in Enum.GetValues(typeof(DataType)))
            {
                expected.DataType = item;
                current.DataType  = item;
                Assert.IsTrue(current.IsMatching(expected), item.ToString());
            }

            expected.DataType = DataType.Integer;
            current.DataType  = DataType.Numeric;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.Integer;
            current.DataType  = DataType.Double;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.Numeric;
            current.DataType  = DataType.Double;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.Double;
            current.DataType  = DataType.Numeric;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.Numeric;
            current.DataType  = DataType.Integer;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.DateTime;
            current.DataType  = DataType.DateTime;
            Assert.IsTrue(current.IsMatching(expected));

            expected.DataType = DataType.DateTime;
            current.DataType  = DataType.String;
            Assert.IsFalse(current.IsMatching(expected));
        }
Ejemplo n.º 14
0
        public void ValueFormatNotEquals()
        {
            var target = new ValueFormatMutable();

            Assert.IsFalse(m_ValueFormatMutableGerman.Equals(target));
        }