public void MlsDelete() { var styles = new AssembledStyles(); var root = new RootBoxFdo(styles.WithWs(23)); var mock1 = new MockData1(23, 23); mock1.MlSimpleOne = new MultiAccessor(23, 23); mock1.MlSimpleOne.set_String(23, TsStrFactoryClass.Create().MakeString("This is it", 23)); var engine = new FakeRenderEngine() { Ws = 23, SegmentHeight = 13 }; var factory = new FakeRendererFactory(); factory.SetRenderer(23, engine); root.Builder.Show(Display.Of(() => mock1.MlSimpleOne, 23)); var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory); root.Layout(layoutArgs); PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96); MockSite site = new MockSite(); site.m_transform = ptrans; site.m_vwGraphics = m_gm.VwGraphics; root.Site = site; SelectionBuilder.In(root).Offset("This ".Length).To.Offset("This is ".Length).Install(); var sel = root.Selection as RangeSelection; // This is currently the main test for SelectionBuilder.In(RootBox) and SelectionBuilder.To in TsStrings // This verifies that it makes roughly the right range selection. Assert.That(sel.Anchor.LogicalParaPosition, Is.EqualTo("This ".Length)); Assert.That(sel.DragEnd.LogicalParaPosition, Is.EqualTo("This is ".Length)); Assert.That(sel.CanDelete(), Is.True); root.OnDelete(); ITsString i = mock1.MlSimpleOne.get_String(23); Assert.That(mock1.MlSimpleOne.get_String(23).Text, Is.EqualTo("This it")); var ip = root.Selection as InsertionPoint; Assert.That(ip.LogicalParaPosition, Is.EqualTo("This ".Length)); // Enhance JohnT: if there is any reason to prefer associatePrevious to be true or false, // clamp that and make it so. // A fairly rudimentary check on invalidate, since we elsewhere check general string-edit ops. Assert.That(site.RectsInvalidatedInRoot, Is.Not.Empty); }