public void GetStrPropValue_DoesNotExist_ReturnsNull() { TsTextProps tps = CreateNonEmptyTextProps(); string value = tps.GetStrPropValue((int)FwTextPropType.ktptParaStyle); Assert.That(value, Is.Null); }
public void GetStrPropValue_Exists_ReturnsCorrectValue() { TsTextProps tps = CreateNonEmptyTextProps(); string value = tps.GetStrPropValue((int)FwTextPropType.ktptFontFamily); Assert.That(value, Is.EqualTo("Arial")); }
public void GetIntProp_IndexOutOfRange_Throws() { TsTextProps tps = TsTextProps.EmptyProps; int tpt, var; Assert.That(() => tps.GetIntProp(0, out tpt, out var), Throws.InstanceOf <ArgumentOutOfRangeException>()); }
private static TsTextProps EditIntProperty(TsTextProps textProps, int tpt, int nVar, int nVal) { ITsPropsBldr tpb = textProps.GetBldr(); tpb.SetIntPropValues(tpt, nVar, nVal); return((TsTextProps)tpb.GetTextProps()); }
private void ReplaceInternal(int ichMin, int ichLim, string insertText, IList <TsRun> insertRuns) { // This is the only case where we can end up with an empty run. if (insertText.Length == 0) { // If we're deleting everything and we were passed a run, use it. if (ichMin == 0 && ichLim == Length) { m_text.Clear(); // If we were given some run properties, let them become those of the empty string. TsTextProps props = insertRuns.Count > 0 ? insertRuns[0].TextProps : m_runs[0].TextProps; m_runs.Clear(); m_runs.Add(new TsRun(0, props)); return; } // We're not deleting everything, therefore any run we were passed describes // no characters and should be ignored. if (insertRuns.Count > 0) { insertRuns = new TsRun[0]; } } int minRunIndex = get_RunAt(ichMin); int limRunIndex = get_RunAt(ichLim); m_text.Remove(ichMin, ichLim - ichMin); m_text.Insert(ichMin, insertText); // dich is the amount that indices >= ichLim should be adjusted by after the replace. int dich = insertText.Length - ichLim + ichMin; SetPropertiesInternal(ichMin, ichLim, minRunIndex, limRunIndex, dich, insertRuns); }
public void Equals_NotSame_ReturnsFalse() { TsTextProps tps1 = TsTextProps.EmptyProps; TsTextProps tps2 = CreateNonEmptyTextProps(); Assert.That(tps1.Equals(tps2), Is.False); }
public void Equals_SameNonEmpty_ReturnsTrue() { TsTextProps tps1 = CreateNonEmptyTextProps(); TsTextProps tps2 = CreateNonEmptyTextProps(); Assert.That(tps1.Equals(tps2), Is.True); }
public void Equals_SameEmpty_ReturnsTrue() { TsTextProps tps1 = TsTextProps.EmptyProps; TsTextProps tps2 = TsTextProps.EmptyProps; Assert.That(tps1.Equals(tps2), Is.True); }
private static TsTextProps EditStrProperty(TsTextProps textProps, int tpt, string strVal) { ITsPropsBldr tpb = textProps.GetBldr(); tpb.SetStrPropValue(tpt, strVal); return((TsTextProps)tpb.GetTextProps()); }
public void GetIntPropValues_DoesNotExist_ReturnsNegativeOne() { TsTextProps tps = CreateNonEmptyTextProps(); int var; int value = tps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var); Assert.That(var, Is.EqualTo(-1)); Assert.That(value, Is.EqualTo(-1)); }
public void GetIntPropValues_Exists_ReturnsCorrectValue() { TsTextProps tps = CreateNonEmptyTextProps(); int var; int value = tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var); Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvDefault)); Assert.That(value, Is.EqualTo(1)); }
public void GetStrProp_ValidIndex_ReturnsCorrectValue() { TsTextProps tps = CreateNonEmptyTextProps(); int tpt; string value = tps.GetStrProp(0, out tpt); Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptFontFamily)); Assert.That(value, Is.EqualTo("Arial")); value = tps.GetStrProp(1, out tpt); Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptFieldName)); Assert.That(value, Is.EqualTo("Field")); }
public void GetIntProp_ValidIndex_ReturnsCorrectValue() { TsTextProps tps = CreateNonEmptyTextProps(); int tpt, var; int value = tps.GetIntProp(0, out tpt, out var); Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptWs)); Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvDefault)); Assert.That(value, Is.EqualTo(1)); value = tps.GetIntProp(2, out tpt, out var); Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptBackColor)); Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvEnum)); Assert.That(value, Is.EqualTo((int)FwTextColor.kclrYellow)); }
/// <summary> /// Creates a text properties object using the specified writing system, old writing system, and a character /// style. The writing system value may be zero which means no writing system is specified. The style may be null. /// If the writing system is zero, then the old writing system must also be zero. An exception will be thrown otherwise. /// </summary> public ITsTextProps MakeProps(string bstrStyle, int ws, int ows) { ThrowIfWSInvalid("ws", ws); var intProps = new Dictionary <int, TsIntPropValue> { { (int)FwTextPropType.ktptWs, new TsIntPropValue(ows, ws) } }; Dictionary <int, string> strProps = null; if (!string.IsNullOrEmpty(bstrStyle)) { strProps = new Dictionary <int, string> { { (int)FwTextPropType.ktptNamedStyle, bstrStyle } }; } return(TsTextProps.GetInternedTextProps(intProps, strProps)); }
public void GetBldr_Empty_ReturnsBldrWithCorrectData() { TsTextProps tps = TsTextProps.EmptyProps; Assert.That(tps.GetBldr().GetTextProps(), Is.EqualTo(tps)); }
internal TsString(string text, TsTextProps textProps) : this(text, new TsRun(text?.Length ?? 0, textProps).ToEnumerable()) { }
internal TsString(string text, int ws) : this(text, TsTextProps.GetInternedTextProps(ws)) { }
public TsRun(int ichLim, TsTextProps textProps) { m_ichLim = ichLim; m_textProps = textProps; }
public void StrPropCount_NonEmpty_ReturnsCorrectCount() { TsTextProps tps = CreateNonEmptyTextProps(); Assert.That(tps.StrPropCount, Is.EqualTo(2)); }
public void StrPropCount_Empty_ReturnsZero() { TsTextProps tps = TsTextProps.EmptyProps; Assert.That(tps.StrPropCount, Is.EqualTo(0)); }
public void GetBldr_NonEmpty_ReturnsBldrWithCorrectData() { TsTextProps tps = CreateNonEmptyTextProps(); Assert.That(tps.GetBldr().GetTextProps(), Is.EqualTo(tps)); }
internal TsStrBldr(string text, TsTextProps textProps) : this(text, new TsRun(text == null ? 0 : text.Length, textProps).ToEnumerable()) { }
/// <summary> /// Creates an <see cref="ITsTextProps"/> from the current state. The number of TextProps may be less then /// the number pushed or inserted do to the compression of like, adjacent values. /// </summary> public ITsTextProps GetTextProps() { return(TsTextProps.GetInternedTextProps(IntProperties, StringProperties)); }