/// <summary> /// Parse a oslc.prefix clause into a map between prefixes /// and corresponding URIs /// <p><b>Note</b>: {@link Object#toString()} of result has been overridden to /// return input expression. /// </summary> /// <param name="prefixExpression">the oslc.prefix expression</param> /// <returns>the prefix map</returns> public static PrefixClause ParsePrefixes(string prefixExpression) { if (prefixExpression == null) { return(new PrefixClause()); } var parser = new OslcPrefixParser(prefixExpression); var rawTree = (CommonTree)parser.Result; IList <ITree> rawPrefixes = rawTree.Children; var prefixMap = new PrefixMap(rawPrefixes.Count); foreach (var iTree in rawPrefixes) { if (!(iTree is CommonTree rawPrefix)) { return(new PrefixClause(isError: true)); } if (rawPrefix.Token == Tokens.Skip || rawPrefix is CommonErrorNode) { return(new PrefixClause(isError: true, errorReason: rawPrefix.ToString())); } string pn = rawPrefix.GetChild(0).Text; string uri = rawPrefix.GetChild(1).Text; uri = uri.Substring(1, uri.Length - 2); prefixMap.Add(pn, uri); } return(new PrefixClause(dictionary: prefixMap)); }
public void PrefixMap_Vector2() { var map = new PrefixMap(SamplePrefixMap); // Should contain 31 builtin refixes + 14 additional Assert.AreEqual(45, map.Count); }
ParsePrefixes( string prefixExpression ) { if (prefixExpression == null) { return(new Dictionary <string, string>()); } OslcPrefixParser parser = new OslcPrefixParser(prefixExpression); CommonTree rawTree = (CommonTree)parser.Result; IList <ITree> rawPrefixes = rawTree.Children; PrefixMap prefixMap = new PrefixMap(rawPrefixes.Count); foreach (CommonTree rawPrefix in rawPrefixes) { if (rawPrefix.Token == Tokens.Skip || rawPrefix is CommonErrorNode) { throw new ParseException(rawPrefix.ToString()); } string pn = rawPrefix.GetChild(0).Text; string uri = rawPrefix.GetChild(1).Text; uri = uri.Substring(1, uri.Length - 2); prefixMap.Add(pn, uri); } return(prefixMap); }
public void PrefixMap_NullInput() { byte[] binaryPrefixMap = null; var map = new PrefixMap(binaryPrefixMap); // Should only contain 19 builtin prefixes Assert.AreEqual(19, map.Count); }
public void test() { var prefixmap = new PrefixMap("./fixture/utau_voice_db/prefix.map"); var actual = prefixmap.getMappedLyric("は", 61); Assert.AreEqual(@"A\は↑", actual); Assert.AreEqual("あ", prefixmap.getMappedLyric("あ", 60)); }
public void PrefixMap_NullInput() { byte[] binaryPrefixMap = null; var map = new PrefixMap(binaryPrefixMap); // Should only contain 31 builtin prefixes Assert.AreEqual(31, map.Count); }
public void Insert_InsertingNewKey_SavesValueToMap(string key, int expectedValue) { // Arrange // Act PrefixMap.Insert(key, expectedValue); var insertedValue = PrefixMap.Map[key]; // Assert Assert.That(insertedValue, Is.EqualTo(expectedValue)); }
public void PrefixMap_TranstaleUser() { var map = new PrefixMap(ExchangeBinaryPrefixMap); // ms-Exch-Admins string oid = map.Translate(827294608); Assert.AreEqual("1.2.840.113556.1.4.7000.102.50064", oid); // ms-Exch-Folder-Affinity-List oid = map.Translate(1210264401); Assert.AreEqual("1.2.840.113556.1.4.7000.102.11089", oid); }
public void Insert_InsertingExistingKey_SavesNewValueToMap(string key, int currentValue, int newValue) { // Arrange // Act PrefixMap.Map.Add(new KeyValuePair <string, int>(key, currentValue)); PrefixMap.Insert(key, newValue); var insertedValue = PrefixMap.Map[key]; // Assert Assert.That(insertedValue, Is.EqualTo(newValue)); }
public void Sum_SumOfValuesWhoseKeyContainsString_IsCorrect() { // Arrange var expectedSum = 5; // Act PrefixMap.Map.Add(new KeyValuePair <string, int>("columnar", 3)); PrefixMap.Map.Add(new KeyValuePair <string, int>("column", 2)); var sum = PrefixMap.Sum("col"); // Assert Assert.That(sum, Is.EqualTo(expectedSum)); }
public void PrefixMap_Vector1() { var map = new PrefixMap(ExchangeBinaryPrefixMap); // Should contain 19 builtin refixes + 6 new Assert.AreEqual(25, map.Count); // Test one of the decoded prefixes bool contains1 = map.ContainsPrefix(18467); Assert.AreEqual(true, contains1); string prefix = map[18467]; Assert.AreEqual("1.2.840.113556.1.4.7000.102", prefix); // Test non-existing prefix bool contains2 = map.ContainsPrefix(1234); Assert.AreEqual(false, contains2); }
public void PrefixMap_TranstaleBuiltin() { var map = new PrefixMap(); // givenName string oid = map.Translate(42); Assert.AreEqual("2.5.4.42", oid); // objectSid oid = map.Translate(589970); Assert.AreEqual("1.2.840.113556.1.4.146", oid); // searchFlags oid = map.Translate(131406); Assert.AreEqual("1.2.840.113556.1.2.334", oid); // Entry-TTL oid = map.Translate(1769475); Assert.AreEqual("1.3.6.1.4.1.1466.101.119.3", oid); }
public void PrefixMap_Vector1() { var map = new PrefixMap(ExchangeBinaryPrefixMap); // Should contain 31 builtin refixes + 6 new Assert.AreEqual(37, map.Count); // Test one of the decoded prefixes bool contains1 = map.ContainsPrefix(18467); Assert.AreEqual(true, contains1); string prefix = map[18467]; Assert.AreEqual("1.2.840.113556.1.4.7000.102", prefix); // Test non-existing prefix bool contains2 = map.ContainsPrefix(1234); Assert.AreEqual(false, contains2); }
/// <summary> /// Initializes a new instance of the <see cref="WampSession"/> class. /// </summary> /// <param name="connection"></param> public WampSession(IWampConnection connection) { Connection = connection; Prefixes = new PrefixMap(); SessionId = IdGenerator.GenerateSessionId(); }
public void PrefixMap_InvalidInput2() { byte[] binaryPrefixMap = { 1, 2, 3, 4, 5, 6, 7, 8 }; var map = new PrefixMap(binaryPrefixMap); }
public void PrefixMap_EmptyInput() { byte[] binaryPrefixMap = new byte[0]; var map = new PrefixMap(binaryPrefixMap); }