@@ -47,6 +47,55 @@ public void ShouldShowAdminActionsWhenLoggedIn()
4747 . FindComponents < AddProfileShortItem > ( ) . Should ( ) . HaveCount ( 1 ) ;
4848 }
4949
50+ [ Fact ]
51+ public void ShouldAddEntry ( )
52+ {
53+ var repo = RegisterServices ( ) ;
54+ ProfileInformationEntry entryToDb = null ;
55+ repo . Setup ( p => p . AddAsync ( It . IsAny < ProfileInformationEntry > ( ) ) )
56+ . Callback < ProfileInformationEntry > ( p => entryToDb = p ) ;
57+ var cut = RenderComponent < Profile > ( p => p . Add ( s => s . IsAuthenticated , true ) ) ;
58+ var addShortItemComponent = cut . FindComponent < AddProfileShortItem > ( ) ;
59+ addShortItemComponent . FindAll ( "input" ) [ 0 ] . Change ( "key" ) ;
60+ addShortItemComponent . FindAll ( "input" ) [ 1 ] . Change ( "value" ) ;
61+
62+ addShortItemComponent . Find ( "button" ) . Click ( ) ;
63+
64+ entryToDb . Should ( ) . NotBeNull ( ) ;
65+ entryToDb . Key . Should ( ) . Be ( "key" ) ;
66+ entryToDb . Value . Should ( ) . Be ( "value" ) ;
67+ }
68+
69+ [ Fact ]
70+ public void ShouldDeleteEntryWhenConfirmed ( )
71+ {
72+ var entryToDelete = new ProfileInformationEntryBuilder ( ) . WithKey ( "key 2" ) . WithCreatedDate ( new DateTime ( 2 ) ) . Build ( ) ;
73+ entryToDelete . Id = "SomeId" ;
74+ var repoMock = RegisterServices ( ) ;
75+ repoMock . Setup ( r => r . GetAllAsync ( ) ) . ReturnsAsync ( new [ ] { entryToDelete } ) ;
76+ var cut = RenderComponent < Profile > ( p => p . Add ( s => s . IsAuthenticated , true ) ) ;
77+ cut . Find ( ".profile-keypoints li button" ) . Click ( ) ;
78+
79+ cut . FindComponent < ConfirmDialog > ( ) . Find ( "#ok" ) . Click ( ) ;
80+
81+ repoMock . Verify ( r => r . DeleteAsync ( "SomeId" ) , Times . Once ) ;
82+ }
83+
84+ [ Fact ]
85+ public void ShouldNotDeleteEntryWhenNotConfirmed ( )
86+ {
87+ var entryToDelete = new ProfileInformationEntryBuilder ( ) . WithKey ( "key 2" ) . WithCreatedDate ( new DateTime ( 2 ) ) . Build ( ) ;
88+ entryToDelete . Id = "SomeId" ;
89+ var repoMock = RegisterServices ( ) ;
90+ repoMock . Setup ( r => r . GetAllAsync ( ) ) . ReturnsAsync ( new [ ] { entryToDelete } ) ;
91+ var cut = RenderComponent < Profile > ( p => p . Add ( s => s . IsAuthenticated , true ) ) ;
92+ cut . Find ( ".profile-keypoints li button" ) . Click ( ) ;
93+
94+ cut . FindComponent < ConfirmDialog > ( ) . Find ( "#cancel" ) . Click ( ) ;
95+
96+ repoMock . Verify ( r => r . DeleteAsync ( "SomeId" ) , Times . Never ) ;
97+ }
98+
5099 private static AppConfiguration CreateEmptyConfiguration ( )
51100 {
52101 return new ( )
0 commit comments