1
1
using System . Linq ;
2
+ using AngleSharp . Dom ;
2
3
using Bunit ;
3
4
using FluentAssertions ;
4
5
using LinkDotNet . Blog . TestUtilities ;
@@ -56,6 +57,27 @@ public void ShouldFillGivenBlogPost()
56
57
blogPostFromComponent . Content . Should ( ) . Be ( "Content" ) ;
57
58
}
58
59
60
+ [ Fact ]
61
+ public void ShouldNotDeleteModelWhenSet ( )
62
+ {
63
+ using var ctx = new TestContext ( ) ;
64
+ BlogPost blogPost = null ;
65
+ var cut = ctx . RenderComponent < CreateNewBlogPost > (
66
+ p => p . Add ( c => c . ClearAfterCreated , true )
67
+ . Add ( c => c . OnBlogPostCreated , post => blogPost = post ) ) ;
68
+ cut . Find ( "#title" ) . Change ( "My Title" ) ;
69
+ cut . Find ( "#short" ) . Change ( "My short Description" ) ;
70
+ cut . Find ( "#content" ) . Change ( "My content" ) ;
71
+ cut . Find ( "#preview" ) . Change ( "My preview url" ) ;
72
+ cut . Find ( "#tags" ) . Change ( "Tag1,Tag2,Tag3" ) ;
73
+ cut . Find ( "form" ) . Submit ( ) ;
74
+ blogPost = null ;
75
+
76
+ cut . Find ( "form" ) . Submit ( ) ;
77
+
78
+ blogPost . Should ( ) . BeNull ( ) ;
79
+ }
80
+
59
81
[ Fact ]
60
82
public void ShouldNotDeleteModelWhenNotSet ( )
61
83
{
@@ -69,12 +91,12 @@ public void ShouldNotDeleteModelWhenNotSet()
69
91
cut . Find ( "#content" ) . Change ( "My content" ) ;
70
92
cut . Find ( "#preview" ) . Change ( "My preview url" ) ;
71
93
cut . Find ( "#tags" ) . Change ( "Tag1,Tag2,Tag3" ) ;
94
+ cut . Find ( "form" ) . Submit ( ) ;
95
+ blogPost = null ;
72
96
73
97
cut . Find ( "form" ) . Submit ( ) ;
74
98
75
- cut .
76
- cut . WaitForState ( ( ) => blogPost != null ) ;
77
- cut . Find ( "#title" ) . TextContent . Should ( ) . Be ( "My Title" ) ;
99
+ blogPost . Should ( ) . NotBeNull ( ) ;
78
100
}
79
101
}
80
102
}
0 commit comments