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