Esempio n. 1
0
        public void TestFixtureSetup()
        {
            //Code that is executed before any test is run in this class. If multiple tests
            // are executed then it will still only be called once.
            _propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null);

            _dataMapper = new GuidDataMapper();
        }
Esempio n. 2
0
        protected static object GetGuidValue(IDictionary <string, string> collection, string lookupItem)
        {
            GuidDataMapper guidDataMapper = new GuidDataMapper();
            object         returnValue;

            guidDataMapper.TryParsePropValue(collection[lookupItem], out returnValue);
            return(returnValue);
        }
Esempio n. 3
0
        public void SetDataMapper_ShouldSetMapperForType()
        {
            //---------------Set up test pack-------------------
            var factory            = new DataMapperFactory();
            var targetType         = typeof(Image);
            var expectedDataMapper = new GuidDataMapper();

            //---------------Execute Test ----------------------
            factory.SetDataMapper(targetType, expectedDataMapper);
            //---------------Test Result -----------------------
            Assert.AreSame(expectedDataMapper, factory.GetDataMapper(targetType));
        }
        /// <summary>
        /// Loads the lookup list data from the reader
        /// </summary>
        protected override void LoadLookupListFromReader()
        {
            string options = _reader.GetAttribute("options");

            if (!string.IsNullOrEmpty(options))
            {
                string[] optionsArr = options.Split(new[] { '|' });
                foreach (string s in optionsArr)
                {
                    _displayValueDictionary.Add(s, s);
                }
            }
            _reader.Read();
            while (_reader.Name == "item")
            {
                string stringPart = _reader.GetAttribute("display");
                string valuePart  = _reader.GetAttribute("value");
                if (string.IsNullOrEmpty(stringPart))
                {
                    throw new InvalidXmlDefinitionException("An 'item' " +
                                                            "is missing a 'display' attribute that specifies the " +
                                                            "string to show to the user in a display.");
                }
                if (string.IsNullOrEmpty(valuePart))
                {
                    throw new InvalidXmlDefinitionException("An 'item' " +

                                                            "is missing a 'value' attribute that specifies the " +
                                                            "value to store for the given property.");
                }
                var  guidDataMapper = new GuidDataMapper();
                Guid newGuid;
                if (StringUtilities.GuidTryParse(valuePart, out newGuid))
                {
                    _displayValueDictionary.Add(stringPart, guidDataMapper.ConvertValueToString(newGuid));
                }
                else
                {
                    _displayValueDictionary.Add(stringPart, valuePart);
                }

                ReadAndIgnoreEndTag();
            }

            if (_displayValueDictionary.Count == 0)
            {
                throw new InvalidXmlDefinitionException("A 'simpleLookupList' " +
                                                        "element does not contain any 'item' elements or any items in the 'options' attribute.  It " +
                                                        "should contain one or more 'item' elements or one or more | separated options in the 'options' attribute that " +
                                                        "specify each of the available options in the lookup list.");
            }
        }