public void CodePoint_ToString() { ICodeModel codeModel = new CodeModel(); var activity = MessageFactory.Text("hi"); var context = new TurnContext(new TestAdapter(), activity); var dc = new DialogContext(new DialogSet(), context, new DialogState()); ICodePoint codePoint = new CodePoint(codeModel, dc, "test-item", "more"); Assert.Equal(codePoint.ToString(), codePoint.Name); }
public void SetBaseType(BaseTypeEnum baseType) { switch (baseType) { case BaseTypeEnum.Octal: CodePointDisplay = Convert.ToString(CodePoint, 8); break; case BaseTypeEnum.Decimal: CodePointDisplay = CodePoint.ToString(); break; case BaseTypeEnum.Hex: CodePointDisplay = Convert.ToString(CodePoint, 16); break; default: throw new Exception("Invalid type"); } }
unsafe public void TestCodePoint() { var s1 = "𢐈"; CodePoint cp = s1; Assert.AreEqual(3, sizeof(CodePoint)); Assert.IsFalse(cp.InBmp); Assert.AreEqual(s1, cp.ToString()); var s2 = "要"; var s3 = "å"; cp = s2; Assert.AreEqual(s2, cp.ToString()); cp = s3; Assert.AreEqual(s3, cp.ToString()); CodePoint[] cpArr = { "的", "a", "b", "𢐈", "的" }; fixed(CodePoint *p = cpArr) { Assert.AreEqual(6, (uint)(p + 2) - (uint)p); Assert.AreEqual("的", p->ToString()); } }
/// <summary> /// Creates a character reference. /// </summary> /// <remarks>The <paramref name="entityName"/> can be passed either in its "entity name" form (e.g. <code>&name;</code>) /// or in its "simple name" form (e.g. <code>name</code>). /// <para>Names (<see cref="EntityName"/> and <see cref="SimpleName"/>) are stored as lower-case, independently of the casing they were provided.</para></remarks> /// <param name="entityName">The name of the reference.</param> /// <exception cref="ArgumentNullException"><paramref name="entityName"/> is null.</exception> internal CharacterReference(string entityName) { Guard.AgainstNullArgument(nameof(entityName), entityName); if (IsEntityName(entityName)) { EntityName = lower(entityName); SimpleName = toSimpleName(entityName); } else { EntityName = toEntityName(entityName); SimpleName = lower(entityName); } Character = _htmlEntities[SimpleName]; CodePoint = char.ConvertToUtf32(Character, 0); EntityNumber = string.Concat(AMP, SHARP, CodePoint.ToString(CultureInfo.InvariantCulture), SEMICOLON); IsEmpty = false; }