Ejemplo n.º 1
0
        public void AsCardListLineTest_DualDated()
        {
            string aCFormat   = null;
            bool   aDualDated = true;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aVal = "1939";

            CommonEnums.DateValType aValType = CommonEnums.DateValType.unknown;

            testVal = new DateObjectModelVal(aVal, aCFormat, aDualDated, aNewYear, aQuality, aValType);

            CardListLineCollection AsCardListLineTest_Basic = testVal.AsCardListLine("Test Title");

            if (AsCardListLineTest_Basic.Title != "Test Title")
            {
                Assert.Fail(); return;
            }

            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[0], "Date:", "1939 (Dual dated)");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[1], "Val:", "1939");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[2], "Dual Dated:", "True");

            Assert.True(AsCardListLineTest_Basic.Count == 3);
        }
Ejemplo n.º 2
0
        public void AsCardListLineTest_After()
        {
            string aCFormat   = null;
            bool   aDualDated = false;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aVal = "1939";

            CommonEnums.DateValType aValType = CommonEnums.DateValType.after;

            testVal = new DateObjectModelVal(aVal, aCFormat, aDualDated, aNewYear, aQuality, aValType);

            CardListLineCollection AsCardListLineTest_After = testVal.AsCardListLine("Test Title");

            if (AsCardListLineTest_After.Title != "Test Title")
            {
                Assert.Fail();
                return;
            }

            CardListLineUtils.CheckCardListLine(AsCardListLineTest_After[0], "Date:", "after 1939");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_After[1], "Val:", "1939");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_After[2], "Type:", "after");

            Assert.True(AsCardListLineTest_After.Count == 3);
        }
Ejemplo n.º 3
0
        public void AsCardListLineTest_DualDated()
        {
            string aCFormat   = null;
            bool   aDualDated = true;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aStart = "1939";
            string aStop  = "1948";

            testVal = new DateObjectModelRange(aStart, aStop, aCFormat, aDualDated, aNewYear, aQuality);

            CardListLineCollection AsCardListLineTest_Basic = testVal.AsCardListLine("Test Title");

            if (AsCardListLineTest_Basic.Title != "Test Title")
            {
                Assert.Fail(); return;
            }

            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[0], "Date:", "Between 1939 and 1948 (Dual dated)");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[1], "Start:", "1939");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[2], "Stop:", "1948");
            CardListLineUtils.CheckCardListLine(AsCardListLineTest_Basic[3], "Dual Dated:", "True");

            Assert.True(AsCardListLineTest_Basic.Count == 4);
        }
Ejemplo n.º 4
0
        public void InitYearOnly()
        {
            string aCFormat   = null;
            bool   aDualDated = false;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aStart = "1939";
            string aStop  = "1948";

            testVal = new DateObjectModelSpan(aStart, aStop, aCFormat, aDualDated, aNewYear, aQuality);
        }
Ejemplo n.º 5
0
        public void InitYearMonthDay()
        {
            string aCFormat   = null;
            bool   aDualDated = false;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aStart = "1939-01-01";
            string aStop  = "1948-10-11";

            testVal = new DateObjectModelRange(aStart, aStop, aCFormat, aDualDated, aNewYear, aQuality);
        }
Ejemplo n.º 6
0
        public void InitYearOnly()
        {
            string aCFormat   = null;
            bool   aDualDated = false;
            string aNewYear   = null;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aVal = "1939";

            CommonEnums.DateValType aValType = CommonEnums.DateValType.unknown;

            testVal = new DateObjectModelVal(aVal, aCFormat, aDualDated, aNewYear, aQuality, aValType);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sets the date range.
        /// </summary>
        /// <param name="argCurrentElement">
        /// The current element.
        /// </param>
        /// <returns>
        /// </returns>
        private static DateObjectModel SetDateRange(XElement argCurrentElement)
        {
            string stringFound;

            string aCFormat   = string.Empty;
            bool   aDualDated = false;
            string aNewYear   = string.Empty;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aStart = string.Empty;
            string aStop  = string.Empty;

            // check for date range
            try
            {
                bool boolFound = false;

                // cformat CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "cformat");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aCFormat = stringFound;
                }

                // dualdated value #REQUIRED
                boolFound = GetBool(argCurrentElement, "dualdated");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aDualDated = boolFound;
                }

                // newyear CDATA #IMPLIED
                stringFound = GetAttribute(argCurrentElement, "newyear");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aNewYear = stringFound;
                }

                // type CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "quality");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    if (!Enum.TryParse(stringFound, out aQuality))
                    {
                        App.Current.Services.GetService <IErrorNotifications>().NotifyError(new ErrorInfo("Bad Date Quality")
                        {
                            { "Element", argCurrentElement.ToString() },
                        });
                    }
                }

                // start CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "start");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aStart = stringFound;
                }

                // stop CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "stop");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aStop = stringFound;
                }
            }
            catch (Exception e)
            {
                // TODO
                App.Current.Services.GetService <IErrorNotifications>().NotifyException("Exception in SetDateRange", e);
                throw;
            }

            return(new DateObjectModelRange(aStart, aStop, aCFormat, aDualDated, aNewYear, aQuality));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sets the date value.
        /// </summary>
        /// <param name="argCurrentElement">
        /// The current element.
        /// </param>
        /// <returns>
        /// </returns>
        public static DateObjectModel SetDateVal(XElement argCurrentElement)
        {
            Contract.Requires(argCurrentElement != null);

            string aCFormat   = string.Empty;
            bool   aDualDated = false;
            string aNewYear   = string.Empty;

            CommonEnums.DateQuality aQuality = CommonEnums.DateQuality.unknown;
            string aVal = string.Empty;

            CommonEnums.DateValType aValType = CommonEnums.DateValType.unknown;

            // check for date range
            try
            {
                bool boolFound = false;

                // cformat CDATA #REQUIRED
                string stringFound = GetAttribute(argCurrentElement, "cformat");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aCFormat = stringFound;
                }

                // dualdated value #REQUIRED
                boolFound = GetBool(argCurrentElement, "dualdated");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aDualDated = boolFound;
                }

                // newyear CDATA #IMPLIED
                stringFound = GetAttribute(argCurrentElement, "newyear");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aNewYear = stringFound;
                }

                // type CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "quality");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    if (!Enum.TryParse(stringFound, out aQuality))
                    {
                        ErrorInfo t = new ErrorInfo("Bad Date Quality")
                        {
                            { "Current Element", argCurrentElement.ToString() }
                        };

                        App.Current.Services.GetService <IErrorNotifications>().NotifyError(t);
                    }
                }

                // type CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "type");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    if (!Enum.TryParse(stringFound, out aValType))
                    {
                        ErrorInfo t = new ErrorInfo("Bad Date Value")
                        {
                            { "Current Element", argCurrentElement.ToString() }
                        };

                        App.Current.Services.GetService <IErrorNotifications>().NotifyError(t);
                    }
                }

                // val CDATA #REQUIRED
                stringFound = GetAttribute(argCurrentElement, "val");
                if (!string.IsNullOrEmpty(stringFound))
                {
                    aVal = stringFound;
                }
            }
            catch (Exception e)
            {
                // TODO
                App.Current.Services.GetService <IErrorNotifications>().NotifyException(e.Message, e);
                throw;
            }

            return(new DateObjectModelVal(aVal, aCFormat, aDualDated, aNewYear, aQuality, aValType));
        }