1 write to Cells
Microsoft.Extensions.Documents.Abstractions (1)
ExtractionDocumentTable.cs (1)
29Cells = new ExtractionDocumentTableCellCollection(this, rowCount, columnCount);
250 references to Cells
Microsoft.Extensions.DocumentExtraction.Abstractions.Tests (5)
DocumentExtractionDocumentBuilderTests.cs (5)
121table.Cells[0, 0] = new ExtractionDocumentTableCell(content); 141Assert.Same(content, table.Cells[0, 0]!.Content); 151Assert.Equal("changed", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 153table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("replacement"))); 154Assert.Equal("replacement", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text);
Microsoft.Extensions.Documents.Abstractions.Tests (245)
DocumentReviewFollowUpTests.cs (10)
124outer.Cells[0, 0] = new(inner); 125outer.Cells[0, 1] = new(inner); 126inner.Cells[0, 0] = new(shared); 127Assert.Same(inner, outer.Cells[0, 0]!.Content); 128Assert.Same(inner, outer.Cells[0, 1]!.Content); 129Assert.Same(shared, inner.Cells[0, 0]!.Content); 135inner.Cells[0, 0] = new(outer); 137Assert.Same(outer, inner.Cells[0, 0]!.Content); 154table.Cells[0, 0] = cell; 164table.Cells[0, 0] = cell;
DocumentTableCellCollectionTests.cs (103)
21table.Cells[0, 1] = new ExtractionDocumentTableCell(firstContent); 22table.Cells[1, 2] = new ExtractionDocumentTableCell(lastContent); 24ExtractionDocumentTableCell?[] cells = table.Cells.ToArray(); 48table.Cells[0, 0] = new ExtractionDocumentTableCell(content); 50ExtractionDocumentTableCell cell = table.Cells[0, 0]!; 52Assert.Same(cell, table.Cells[0, 0]); 68table.Cells[0, 0] = new ExtractionDocumentTableCell(image); 70ExtractionDocumentImageElement actual = Assert.IsType<ExtractionDocumentImageElement>(table.Cells[0, 0]!.Content); 89table.Cells[0, 0] = new ExtractionDocumentTableCell(oldContent); 90ExtractionDocumentTableCell oldCell = table.Cells[0, 0]!; 92table.Cells[0, 0] = new ExtractionDocumentTableCell(replacementContent); 94ExtractionDocumentTableCell replacementCell = table.Cells[0, 0]!; 100table.Cells[0, 0] = null; 102Assert.Null(table.Cells[0, 0]); 114firstTable.Cells[0, 0] = cell; 116Assert.Throws<InvalidOperationException>(() => secondTable.Cells[0, 0] = cell); 118Assert.Same(cell, firstTable.Cells[0, 0]); 119Assert.Null(secondTable.Cells[0, 0]); 120Assert.Same(content, firstTable.Cells[0, 0]!.Content); 166table.Cells[0, 1] = cell; 168Assert.Same(cell, table.Cells[0, 1]); 175Assert.Null(table.Cells[0, 0]); 178Assert.Null(table.Cells[row, column]); 179Assert.True(table.Cells.IsCovered(row, column)); 180Assert.Same(cell, table.Cells.GetCoveringCell(row, column)); 260table.Cells[0, 0] = cell; 270innerTable.Cells[0, 0] = new ExtractionDocumentTableCell(root); 279Assert.Same(cell, table.Cells[0, 0]); 286Assert.Same(root, innerTable!.Cells[0, 0]!.Content); 303Assert.Throws<InvalidOperationException>(() => table.Cells[0, 0] = new ExtractionDocumentTableCell(table)); 305Assert.Null(table.Cells[0, 0]); 314outerTable.Cells[0, 0] = new ExtractionDocumentTableCell(innerTable); 316innerTable.Cells[0, 0] = new ExtractionDocumentTableCell(outerTable); 323Assert.Same(innerTable, outerTable.Cells[0, 0]!.Content); 324Assert.Same(outerTable, innerTable.Cells[0, 0]!.Content); 337table.Cells[0, 0] = new ExtractionDocumentTableCell(content); 338ExtractionDocumentTableCell cell = table.Cells[0, 0]!; 340table.Cells[0, 0] = cell; 342Assert.Same(cell, table.Cells[0, 0]); 345table.Cells[0, 0] = null; 346table.Cells[0, 0] = null; 348Assert.Null(table.Cells[0, 0]); 360table.Cells[0, 0] = anchor; 361table.Cells[2, 0] = ordinary; 368Assert.False(table.Cells.IsCovered(0, 0)); 371Assert.Null(table.Cells[row, column]); 372Assert.True(table.Cells.IsCovered(row, column)); 373Assert.Same(anchor, table.Cells.GetCoveringCell(row, column)); 376Assert.Null(table.Cells[2, 2]); 377Assert.False(table.Cells.IsCovered(2, 2)); 378Assert.Null(table.Cells.GetCoveringCell(2, 2)); 379Assert.Equal(new ExtractionDocumentTableCell?[] { anchor, null, null, null, null, null, ordinary, null, null }, table.Cells.ToArray()); 392table.Cells[0, 0] = anchor; 395ExtractionDocumentTableCell?[] before = table.Cells.ToArray(); 399Assert.Throws<InvalidOperationException>(() => table.Cells[0, 1] = candidate); 400Assert.Throws<InvalidOperationException>(() => table.Cells[1, 1] = null); 401Assert.Throws<InvalidOperationException>(() => table.Cells[1, 0] = null); 402table.Cells[2, 2] = candidate; 403Assert.Throws<InvalidOperationException>(() => table.Cells[1, 2] = overlap); 404Assert.Throws<InvalidOperationException>(() => table.Cells[2, 1] = candidate); 405table.Cells[2, 2] = null; 406Assert.Equal(before, table.Cells.ToArray()); 410table.Cells[0, 0] = null; 411Assert.False(table.Cells.IsCovered(1, 1)); 412Assert.Null(table.Cells.GetCoveringCell(1, 1)); 428Assert.Throws<ArgumentException>("cell", () => table.Cells[2, 2] = candidate); 429Assert.Null(table.Cells[2, 2]); 430table.Cells[0, 0] = candidate; 441table.Cells[1, 1] = anchor; 448ExtractionDocumentTableCell?[] before = table.Cells.ToArray(); 451Assert.Null(table.Cells[0, 2]); 452Assert.False(table.Cells.IsCovered(0, 2)); 453Assert.Null(table.Cells.GetCoveringCell(0, 2)); 454Assert.Null(table.Cells[1, 2]); 455Assert.True(table.Cells.IsCovered(1, 2)); 456Assert.Same(anchor, table.Cells.GetCoveringCell(1, 2)); 458Assert.Throws<InvalidOperationException>(() => table.Cells[0, 2] = candidate); 460Assert.Equal(before, table.Cells.ToArray()); 466Assert.Equal(inAnchor && (row != 1 || column != 1), table.Cells.IsCovered(row, column)); 467Assert.Same(inAnchor ? anchor : null, table.Cells.GetCoveringCell(row, column)); 471Assert.Same(anchor, table.Cells[1, 1]); 482otherTable.Cells[0, 0] = candidate; 484Assert.Same(candidate, otherTable.Cells[0, 0]); 485Assert.Same(candidate, otherTable.Cells.GetCoveringCell(1, 0)); 486Assert.True(otherTable.Cells.IsCovered(1, 0)); 489Assert.Equal(before, table.Cells.ToArray()); 511table.Cells[0, 0] = oldAnchor; 515Assert.Same(oldAnchor, table.Cells.GetCoveringCell(1, 1)); 516Assert.True(table.Cells.IsCovered(1, 1)); 520table.Cells[0, 0] = replacement; 522Assert.Same(replacement, table.Cells.GetCoveringCell(0, 0)); 525Assert.Null(table.Cells[row, column]); 526Assert.Null(table.Cells.GetCoveringCell(row, column)); 527Assert.False(table.Cells.IsCovered(row, column)); 536table.Cells[0, 1] = empty; 537Assert.Same(empty, table.Cells.GetCoveringCell(0, 1)); 538Assert.False(table.Cells.IsCovered(0, 1)); 539table.Cells[2, 2] = oldAnchor; 541Assert.Equal(4, table.Cells.RowCount); 542Assert.Equal(4, table.Cells.ColumnCount); 569Assert.Same(covering, table.Cells.GetCoveringCell(row, column)); 570Assert.Equal(row >= 2 && column >= 2 && (row != 2 || column != 2), table.Cells.IsCovered(row, column)); 580table.Cells.ToArray());
DocumentTableCellTests.cs (19)
21table.Cells[1, 0] = new ExtractionDocumentTableCell(content); 25ExtractionDocumentTableCell cell = table.Cells[1, 0]!; 40table.Cells[0, 0] = new ExtractionDocumentTableCell(content); 45ExtractionDocumentTableCell cell = table.Cells[0, 0]!; 50Assert.Same(cell, table.Cells[0, 0]); 81table.Cells[0, 0] = content; 82table.Cells[0, 1] = empty; 92Assert.Equal(new ExtractionDocumentTableCell?[] { content, empty }, table.Cells); 122table.Cells[2, 2] = empty; 131Assert.False(table.Cells.IsCovered(2, 2)); 132Assert.Same(empty, table.Cells.GetCoveringCell(2, 2)); 133Assert.Null(table.Cells.GetCoveringCell(1, 2)); 172table.Cells[0, 1] = empty; 173table.Cells[0, 2] = ordinary; 189Assert.Same(empty, table.Cells.GetCoveringCell(0, 1)); 190Assert.False(table.Cells.IsCovered(0, 1)); 191Assert.Null(table.Cells.GetCoveringCell(0, 0)); 193var sources = table.Cells.GetCoveringCell(0, 1)!.Sources; 207Assert.Empty(table.Cells.GetCoveringCell(0, 2)!.Content!.Sources);
DocumentTableElementTests.cs (96)
21inner.Cells[0, 0] = new ExtractionDocumentTableCell(leaf); 22middle.Cells[0, 0] = new ExtractionDocumentTableCell(inner); 23outer.Cells[0, 0] = new ExtractionDocumentTableCell(middle); 25Assert.Same(leaf, inner.Cells[0, 0]!.Content); 26Assert.Same(inner, middle.Cells[0, 0]!.Content); 27Assert.Same(middle, outer.Cells[0, 0]!.Content); 41inner.Cells[0, 0] = first; 42inner.Cells[0, 1] = new ExtractionDocumentTableCell(image); 44outer.Cells[0, 0] = new ExtractionDocumentTableCell(inner); 49Assert.Same(image, inner.Cells[0, 1]!.Content); 50Assert.Equal(1, inner.Cells.RowCount); 51Assert.Equal(2, inner.Cells.ColumnCount); 64table.Cells[0, 0] = wide; 65table.Cells[2, 3] = corner; 68Assert.Throws<InvalidOperationException>(() => table.Cells[1, 1] = new ExtractionDocumentTableCell()); 69Assert.Throws<InvalidOperationException>(() => table.Cells[0, 3] = new ExtractionDocumentTableCell(3, 1)); 70Assert.Throws<ArgumentException>(() => table.Cells[0, 0] = new ExtractionDocumentTableCell(4, 1)); 74table.Cells[0, 0] = small; 76table.Cells[0, 0] = null; 78table.Cells[0, 0] = wide; 90Assert.Same(expected, table.Cells.GetCoveringCell(row, column)); 92table.Cells.IsCovered(row, column)); 94table.Cells[row, column]); 106Assert.Equal(2, table.Cells.RowCount); 107Assert.Equal(3, table.Cells.ColumnCount); 110table.Cells.ToArray()); 130Assert.Equal(rowCount, table.Cells.RowCount); 131Assert.Equal(columnCount, table.Cells.ColumnCount); 132Assert.Empty(table.Cells); 149() => _ = table.Cells[row, column]); 152() => table.Cells[row, column] = candidate); 155() => table.Cells[row, column] = null); 160table.Cells.ToArray()); 167table.Cells[0, 1] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("one"))); 168table.Cells[1, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("two"))); 170Assert.Equal(6, table.Cells.Count()); 171Assert.Null(table.Cells[0, 0]); 172Assert.Null(table.Cells[0, 2]); 173Assert.Null(table.Cells[1, 1]); 174Assert.Null(table.Cells[1, 2]); 175Assert.Equal("one", Assert.IsType<TextContent>(table.Cells[0, 1]!.Content!.Content).Text); 176Assert.Equal("two", Assert.IsType<TextContent>(table.Cells[1, 0]!.Content!.Content).Text); 183table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("left|right"))); 185Assert.Equal("left|right", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 192table.Cells[0, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("semantic cell"))); 195Assert.Equal("semantic cell", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 203table.Cells[0, 0] = anchor; 204table.Cells[2, 0] = new ExtractionDocumentTableCell(new ExtractionDocumentTextElement(new TextContent("B")), role: "rowHeader"); 206table.Cells[2, 2] = empty; 207ExtractionDocumentTableCell?[] before = table.Cells.ToArray(); 209Assert.Equal(before, table.Cells.ToArray()); 212Assert.Equal("rowHeader", table.Cells[2, 0]!.Role); 214Assert.Same(anchor, table.Cells.GetCoveringCell(1, 1)); 215Assert.Null(table.Cells[1, 1]); 216Assert.False(table.Cells.IsCovered(2, 2)); 237table.Cells[0, 0] = cell; 246Assert.Same(cell, table.Cells.GetCoveringCell(0, 0)); 247Assert.False(table.Cells.IsCovered(0, 0)); 261table.Cells[0, 0] = empty; 262table.Cells[1, 1] = anchor; 266Assert.Equal(3, table.Cells.RowCount); 267Assert.Equal(4, table.Cells.ColumnCount); 276table.Cells.ToArray()); 288Assert.Same(covering, table.Cells.GetCoveringCell(row, column)); 289Assert.Equal(inSpan && (row != 1 || column != 1), table.Cells.IsCovered(row, column)); 308table.Cells[0, 1] = empty; 309table.Cells[0, 2] = new ExtractionDocumentTableCell(text); 313Assert.Null(table.Cells[0, 0]); 314Assert.Null(table.Cells.GetCoveringCell(0, 0)); 315Assert.False(table.Cells.IsCovered(0, 0)); 316Assert.Same(empty, table.Cells.GetCoveringCell(0, 1)); 317Assert.False(table.Cells.IsCovered(0, 1)); 328table.Cells[0, 1] = null; 330Assert.Null(table.Cells[0, 1]); 331Assert.Null(table.Cells.GetCoveringCell(0, 1)); 346Assert.Equal(2, table.Cells.RowCount); 347Assert.Equal(2, table.Cells.ColumnCount); 348Assert.Equal(new ExtractionDocumentTableCell?[] { null, null, null, null }, table.Cells.ToArray()); 349Assert.Null(table.Cells.GetCoveringCell(0, 0)); 350Assert.False(table.Cells.IsCovered(0, 0)); 355Assert.Equal(new ExtractionDocumentTableCell?[] { null, null, null, null }, table.Cells.ToArray()); 367table.Cells[1, 1] = empty; 374Assert.Equal(new ExtractionDocumentTableCell?[] { null, null, null, empty }, table.Cells.ToArray()); 376Assert.Same(empty, table.Cells.GetCoveringCell(1, 1)); 377Assert.False(table.Cells.IsCovered(1, 1)); 378Assert.Null(table.Cells.GetCoveringCell(0, 0)); 392table.Cells[0, 0] = populated; 393table.Cells[1, 1] = empty; 400table.Cells[0, 0] = null; 402Assert.Same(empty, table.Cells.GetCoveringCell(1, 1)); 403table.Cells[1, 1] = null; 407Assert.Equal(new ExtractionDocumentTableCell?[] { null, null, null, null }, table.Cells.ToArray()); 408Assert.Equal(2, table.Cells.RowCount); 409Assert.Equal(2, table.Cells.ColumnCount); 417Assert.Null(table.Cells.GetCoveringCell(row, column)); 418Assert.False(table.Cells.IsCovered(row, column));
DocumentTests.Composition.cs (5)
33table.Cells[0, 0] = empty; 34table.Cells[0, 1] = new ExtractionDocumentTableCell(cellText); 91table.Cells[0, 0] = new ExtractionDocumentTableCell(cellText); 92table.Cells[0, 1] = new ExtractionDocumentTableCell(); 108Assert.All(table.Cells, cell => Assert.Empty(cell!.Sources));
DocumentTests.StandardContent.cs (12)
135table.Cells[0, 0] = new ExtractionDocumentTableCell(cellContent); 138Assert.Same(cellContent, table.Cells[0, 0]!.Content); 170table.Cells[0, 0] = new ExtractionDocumentTableCell(cellText); 179Assert.Same(cellText, table.Cells[0, 0]!.Content); 183Assert.Equal("edited", Assert.IsType<TextContent>(table.Cells[0, 0]!.Content!.Content).Text); 220table.Cells[0, 0] = new ExtractionDocumentTableCell(text); 230Assert.Same(text, table.Cells[0, 0]!.Content); 402table.Cells[0, 0] = firstCell; 403table.Cells[0, 1] = new ExtractionDocumentTableCell(second); 407Assert.Same(firstCell, table.Cells[0, 0]); 408Assert.Same(first, table.Cells[0, 0]!.Content); 409Assert.Same(second, table.Cells[0, 1]!.Content);