Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ce0425d

Browse files
More unit test improvements
1 parent 4724715 commit ce0425d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/UnitTests/GitHub.App/Models/AccountModelTests.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void CopyFromDoesNotLoseAvatar()
2121
var userImage = AvatarProvider.CreateBitmapImage("pack://application:,,,/GitHub.App;component/Images/default_user_avatar.png");
2222
var orgImage = AvatarProvider.CreateBitmapImage("pack://application:,,,/GitHub.App;component/Images/default_org_avatar.png");
2323

24-
var bitmapImageObservable = new Subject<BitmapImage>();
24+
var initialBitmapImageSubject = new Subject<BitmapImage>();
2525

2626
var collectionEvent = new ManualResetEvent(false);
2727
var avatarPropertyEvent = new ManualResetEvent(false);
@@ -30,7 +30,7 @@ public void CopyFromDoesNotLoseAvatar()
3030
const string login = "foo";
3131
const int initialOwnedPrivateRepositoryCount = 1;
3232

33-
var initialAccount = new Account(login, true, false, initialOwnedPrivateRepositoryCount, 0, bitmapImageObservable);
33+
var initialAccount = new Account(login, true, false, initialOwnedPrivateRepositoryCount, 0, initialBitmapImageSubject);
3434

3535
//Creating the test collection
3636
var col = new TrackingCollection<IAccount>(Observable.Empty<IAccount>(), OrderedComparer<IAccount>.OrderByDescending(x => x.Login).Compare);
@@ -63,7 +63,8 @@ public void CopyFromDoesNotLoseAvatar()
6363
});
6464

6565
//Providing the first avatar
66-
bitmapImageObservable.OnNext(userImage);
66+
initialBitmapImageSubject.OnNext(userImage);
67+
initialBitmapImageSubject.OnCompleted();
6768

6869
//Waiting for the avatar to be added
6970
avatarPropertyEvent.WaitOne();
@@ -76,7 +77,8 @@ public void CopyFromDoesNotLoseAvatar()
7677

7778
//Creating an account update
7879
const int updatedOwnedPrivateRepositoryCount = 2;
79-
var updatedAccount = new Account(login, true, false, updatedOwnedPrivateRepositoryCount, 0, bitmapImageObservable);
80+
var updatedBitmapImageSubject = new Subject<BitmapImage>();
81+
var updatedAccount = new Account(login, true, false, updatedOwnedPrivateRepositoryCount, 0, updatedBitmapImageSubject);
8082

8183
//Updating the account in the collection
8284
col.AddItem(updatedAccount);
@@ -86,7 +88,8 @@ public void CopyFromDoesNotLoseAvatar()
8688
collectionEvent.Reset();
8789

8890
//Providing the second avatar
89-
bitmapImageObservable.OnNext(orgImage);
91+
updatedBitmapImageSubject.OnNext(orgImage);
92+
updatedBitmapImageSubject.OnCompleted();
9093

9194
//Waiting for the delayed bitmap image observable
9295
avatarPropertyEvent.WaitOne();

0 commit comments

Comments
 (0)