Skip to content

Commit c48eea9

Browse files
committed
Unit test for drag and drop behavior
1 parent 22bd8f9 commit c48eea9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

LinkDotNet.Blog.IntegrationTests/Web/Shared/ProfileTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using AngleSharp.Dom;
23
using Bunit;
34
using FluentAssertions;
45
using LinkDotNet.Blog.TestUtilities;
@@ -117,7 +118,22 @@ public void ShouldAddEntryWithCorrectSortOrder()
117118
[Fact]
118119
public void ShouldSetNewOrderWhenItemDragAndDropped()
119120
{
121+
var target = new ProfileInformationEntryBuilder().WithSortOrder(100).Build();
122+
var source = new ProfileInformationEntryBuilder().WithSortOrder(200).Build();
123+
var (repo, calculator) = RegisterServices();
124+
var profileInformationEntries = new List<ProfileInformationEntry> { target, source };
125+
repo.Setup(p => p.GetAllAsync()).ReturnsAsync(profileInformationEntries);
126+
ProfileInformationEntry entryToDb = null;
127+
repo.Setup(p => p.StoreAsync(It.IsAny<ProfileInformationEntry>()))
128+
.Callback<ProfileInformationEntry>(p => entryToDb = p);
129+
var cut = RenderComponent<Profile>(p => p.Add(s => s.IsAuthenticated, true));
130+
calculator.Setup(s => s.GetSortOrder(target, profileInformationEntries)).Returns(150);
131+
132+
cut.FindAll("li")[1].Drag();
133+
cut.FindAll("li")[0].Drop();
120134

135+
source.SortOrder.Should().Be(150);
136+
entryToDb.Should().Be(source);
121137
}
122138

123139
private static AppConfiguration CreateEmptyConfiguration()

LinkDotNet.Domain/ProfileInformationEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace LinkDotNet.Domain
55
{
6-
[DebuggerDisplay("{Content}")]
6+
[DebuggerDisplay("{Content} with sort order {SortOrder}")]
77
public class ProfileInformationEntry
88
{
99
private ProfileInformationEntry()

0 commit comments

Comments
 (0)