Exemple #1
0
        public void SimpleDeprecatedPropertyIsKnown()
        {
            var loseOnTimeProperty = SgfKnownProperties.Get("LT");

            Assert.AreEqual("LT", loseOnTimeProperty.Identifier);
            Assert.IsNull(loseOnTimeProperty.Parser);
            Assert.AreEqual(SgfValueMultiplicity.None, loseOnTimeProperty.ValueMultiplicity);
            Assert.AreEqual(SgfPropertyType.Deprecated, loseOnTimeProperty.Type);
        }
Exemple #2
0
        public void SimpleBlackMovePropertyIsKnown()
        {
            var blackMoveProperty = SgfKnownProperties.Get("B");

            Assert.AreEqual("B", blackMoveProperty.Identifier);
            Assert.AreEqual(SgfPointValue.Parse, blackMoveProperty.Parser);
            Assert.AreEqual(SgfValueMultiplicity.Single, blackMoveProperty.ValueMultiplicity);
            Assert.AreEqual(SgfPropertyType.Move, blackMoveProperty.Type);
        }
 /// <summary>
 /// Searches a SGF game tree for game-info properties
 /// </summary>
 /// <param name="gameTree">SGF game tree</param>
 private void SearchGameTree(SgfGameTree gameTree)
 {
     foreach (var child in gameTree.Children)
     {
         SearchGameTree(child);
     }
     //gather game-info properties from this node
     foreach (var node in gameTree.Sequence)
     {
         foreach (var property in node)
         {
             var knownProperty = SgfKnownProperties.Get(property.Identifier);
             if (knownProperty != null && knownProperty.Type == SgfPropertyType.GameInfo)
             {
                 _gameInfoProperties[property.Identifier] = property;
             }
         }
     }
 }
        /// <summary>
        /// Returns the parsed values for a given property
        /// </summary>
        /// <param name="propertyIdentifier">Identifier of the property</param>
        /// <param name="values">Value to convert</param>
        /// <returns>Converted value</returns>
        public static IEnumerable <ISgfPropertyValue> GetValues(string propertyIdentifier, params string[] values)
        {
            if (propertyIdentifier == null)
            {
                throw new ArgumentNullException(nameof(propertyIdentifier));
            }
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            //is the property known?
            var property = SgfKnownProperties.Get(propertyIdentifier);

            if (property != null)
            {
                return(ParseValues(values, property.Parser));
            }
            //return as unknown property
            return(ParseValues(values, SgfUnknownValue.Parse));
        }
Exemple #5
0
 public void TryingToGetNullKnownPropertyThrows()
 {
     SgfKnownProperties.Get(null);
 }