-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51b34e7
commit 460ad81
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
tests/DynamicTreeDataGrid.Tests/Columns/DynamicColumnListTests/ColumnStates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using DynamicTreeDataGrid.Columns; | ||
using DynamicTreeDataGrid.State; | ||
|
||
using Microsoft.Reactive.Testing; | ||
|
||
namespace DynamicTreeDataGrid.Tests.Columns.DynamicColumnListTests; | ||
|
||
public class ColumnStates { | ||
private readonly TestScheduler _scheduler = new(); | ||
private readonly DynamicColumnList<TestPerson> _list = []; | ||
|
||
private readonly List<ColumnState> _loadedStates = [ | ||
new("Id") { Index = 2, Visible = true }, | ||
new("Name") { Index = 0, Visible = true }, | ||
new("Date-of-Birth") { Index = 1, Visible = true }, | ||
]; | ||
|
||
[Before(Test)] | ||
public async Task Setup() { | ||
await Task.CompletedTask; | ||
// Build the collection with specific indexes | ||
_list.Insert(0, new DynamicTextColumn<TestPerson, int>("Id", "Id", person => person.Id)); | ||
_list.Insert(1, new DynamicTextColumn<TestPerson, string>("Name", "Name", person => person.Name)); | ||
_list.Insert(2, | ||
new DynamicTextColumn<TestPerson, DateTime>("Date-of-Birth", "DoB", person => person.DateOfBirth)); | ||
} | ||
|
||
[After(Test)] | ||
public async Task CleanupAfterTests() { await Task.CompletedTask; } | ||
|
||
[Test] | ||
public async Task Default_Collection_State() { | ||
await Assert.That(_list.Count).IsEqualTo(3); | ||
|
||
// Check that all items are in the right order and visible | ||
await Assert.That(_list[0].Name).IsEqualTo("Id"); | ||
await Assert.That(_list[0].Visible).IsEqualTo(true); | ||
await Assert.That(_list[1].Name).IsEqualTo("Name"); | ||
await Assert.That(_list[1].Visible).IsEqualTo(true); | ||
await Assert.That(_list[2].Name).IsEqualTo("Date-of-Birth"); | ||
await Assert.That(_list[2].Visible).IsEqualTo(true); | ||
} | ||
|
||
[Test] | ||
public async Task GetColumnStates_ReturnsAllStates() { | ||
var result = _list.GetColumnStates(); | ||
|
||
// Check that all items are in the right order and visible | ||
await Assert.That(result.Count()).IsEqualTo(3); | ||
} | ||
} |