Skip to content

Commit

Permalink
#44 Napisan dio koda kako bi test prošao
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarkoovin21 committed Jun 14, 2024
1 parent 85477b0 commit b283806
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ private decimal CalculateMembershipDurationFromDate(DateTime date) {
public int MembershipExpieringSoon()
{
DateTime? membershipDate = membersRepository.GetMembershipDate(LoggedUser.Username);
if (membershipDate == null)
{
return 0;
}
return 5;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ public void MembershipExpieringSoon_GivenMembershipExpiresIn5days_ReturnDaysUnti

[Fact]

public void MembershipExpieringSoon_GivenInvalidUsername_ReturnsNull()
public void MembershipExpieringSoon_GivenInvalidUsername_EqualsNull()
{
// Arrange
string username = "nonexisting";
A.CallTo(() => membersRepository.GetMembershipDate(username)).Returns(null);
A.CallTo(() => membersRepository.GetMembershipDate(username)).Returns((DateTime?)null);

// Act
var daysUntilExpiration = memberService.MembershipExpieringSoon();

// Assert
Assert.Null(daysUntilExpiration);
Assert.Equal(daysUntilExpiration, 0);
}
}
}

0 comments on commit b283806

Please sign in to comment.