Skip to content

Commit

Permalink
minor assertions fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanRomashkov committed Apr 26, 2021
1 parent 330f836 commit c054a54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions DotsTests/NoticesRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task TestGetNotices()
IEnumerable<Notice> notices = await _noticesRepository.GetNoticesAsync("60848ae8fb71edf2a7ebf846");

Assert.NotNull(notices);
Assert.AreEqual(notices.Count(), 1);
Assert.AreEqual(1, notices.Count());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -82,7 +82,7 @@ public async Task TestAddNotice()

IEnumerable<Notice> notices = await _noticesRepository.GetNoticesAsync("60848ae8fb71edf2a7ebf846");

Assert.AreEqual(notices.Count(), 2);
Assert.AreEqual(2, notices.Count());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -113,7 +113,7 @@ public async Task TestUpdateNotice()
notice.Name = "Name Changed";
await _noticesRepository.UpdateNoticeAsync(notice);
notice = getNotice(UserId, NoticeId);
Assert.AreEqual(notice.Name, "Name Changed");
Assert.AreEqual("Name Changed", notice.Name);

DateTime oldTime = notice.TimeCompleted;
notice.TimeCompleted = notice.TimeCompleted.AddMinutes(30);
Expand All @@ -125,8 +125,8 @@ public async Task TestUpdateNotice()
notice.TimeCompleted = oldTime;
await _noticesRepository.UpdateNoticeAsync(notice);
notice = getNotice(UserId, NoticeId);
Assert.AreEqual(notice.Name, "changed again");
Assert.AreEqual(notice.TimeCompleted, oldTime);
Assert.AreEqual("changed again", notice.Name);
Assert.AreEqual(oldTime, notice.TimeCompleted);
}
catch (Exception ex)
{
Expand All @@ -145,7 +145,7 @@ public async Task TestDeleteNotice()
try
{
User user = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();
Assert.AreEqual(user.Notices.Count(), 1);
Assert.AreEqual(1, user.Notices.Count());

await _noticesRepository.DeleteNoticeAsync(user.Id, "608235aea059ac5c9af6da20");
user = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();
Expand Down
4 changes: 2 additions & 2 deletions DotsTests/UsersControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public async Task TestAuthenticate()

OkObjectResult result = await _usersController.AuthenticateAsync(dto) as OkObjectResult;
BsonDocument elements = result.Value.ToBsonDocument();
Assert.AreEqual(elements.GetValue("_id").ToString(), "60848ae8fb71edf2a7ebf846");
Assert.AreEqual(elements.GetValue("Email").ToString(), dto.Email);
Assert.AreEqual("60848ae8fb71edf2a7ebf846", elements.GetValue("_id").ToString());
Assert.AreEqual(dto.Email, elements.GetValue("Email").ToString());
Assert.NotNull(elements.GetValue("Token"));

dto.Email = "nonExistentEmail";
Expand Down
12 changes: 6 additions & 6 deletions DotsTests/UsersRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task TestGetUserById()
User user = await _usersRepository.GetUserByIdAsync("60848ae8fb71edf2a7ebf846");

Assert.IsNotNull(user);
Assert.AreEqual(user.Email, "[email protected]");
Assert.AreEqual("[email protected]", user.Email);
}

[Test]
Expand All @@ -44,7 +44,7 @@ public async Task TestGetUserByEmail()
User user = await _usersRepository.GetUserByEmailAsync("[email protected]");

Assert.IsNotNull(user);
Assert.AreEqual(user.Id, "60848ae8fb71edf2a7ebf846");
Assert.AreEqual("60848ae8fb71edf2a7ebf846", user.Id);
}

[Test]
Expand Down Expand Up @@ -98,8 +98,8 @@ public async Task TestAuthenticate()
User result = await _usersRepository.AuthenticateAsync(email, password);

Assert.IsNotNull(result);
Assert.AreEqual(result.Id, "60848ae8fb71edf2a7ebf846");
Assert.AreEqual(result.Email, email);
Assert.AreEqual("60848ae8fb71edf2a7ebf846", result.Id);
Assert.AreEqual(email, result.Email);
Assert.True(BCrypt.Net.BCrypt.Verify(password, result.PasswordHash));
}
catch (Exception ex)
Expand Down Expand Up @@ -138,7 +138,7 @@ public async Task TestUpdateUser()
await _usersRepository.UpdateUserAsync(replacement);
User updatedUser = await _usersCollection.Find(u => u.Email == "newEmail").FirstOrDefaultAsync();
Assert.NotNull(updatedUser);
Assert.AreEqual(updatedUser.Id, replacement.Id);
Assert.AreEqual(replacement.Id, updatedUser.Id);

await _usersRepository.UpdateUserAsync(updatedUser, "newPassword");
updatedUser = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();
Expand All @@ -148,7 +148,7 @@ public async Task TestUpdateUser()

await _usersRepository.UpdateUserAsync(replacement, "oldPassword");
updatedUser = await _usersCollection.Find(u => u.Id == "60848ae8fb71edf2a7ebf846").FirstOrDefaultAsync();
Assert.AreEqual(updatedUser.Email, "[email protected]");
Assert.AreEqual("[email protected]", updatedUser.Email);
Assert.True(BCrypt.Net.BCrypt.Verify("oldPassword", updatedUser.PasswordHash));
}
catch (Exception ex)
Expand Down

0 comments on commit c054a54

Please sign in to comment.