Skip to content

Commit

Permalink
Merge pull request #1385 from rabbitmq/lukebakken/fix-equal-usage
Browse files Browse the repository at this point in the history
Ensure that the order of arguments is `expected`, `actual`
  • Loading branch information
lukebakken authored Sep 12, 2023
2 parents 6668107 + 7116401 commit b01f75c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion projects/Unit/Helper/RequestFormMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Func<string, bool> Matcher()
foreach (string k in actual.Keys)
{
Assert.NotNull(_expected[k]);
Assert.Equal(actual[k], _expected[k]);
Assert.Equal(_expected[k], actual[k]);
}
return true;
};
Expand Down
12 changes: 6 additions & 6 deletions projects/Unit/TestOAuth2Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public void TestRequestToken()

IToken token = _client.RequestToken();
Assert.NotNull(token);
Assert.Equal(token.AccessToken, expectedJsonToken.access_token);
Assert.Equal(token.RefreshToken, expectedJsonToken.refresh_token);
Assert.Equal(token.ExpiresIn, TimeSpan.FromSeconds(expectedJsonToken.expires_in));
Assert.Equal(expectedJsonToken.access_token, token.AccessToken);
Assert.Equal(expectedJsonToken.refresh_token, token.RefreshToken);
Assert.Equal(TimeSpan.FromSeconds(expectedJsonToken.expires_in), token.ExpiresIn);
}

private void expectTokenRefresh(JsonToken expectedResponse)
Expand Down Expand Up @@ -134,9 +134,9 @@ public void TestRefreshToken()
IToken refreshedToken = _client.RefreshToken(token);
Assert.False(refreshedToken == token);
Assert.NotNull(refreshedToken);
Assert.Equal(refreshedToken.AccessToken, expectedJsonToken.access_token);
Assert.Equal(refreshedToken.RefreshToken, expectedJsonToken.refresh_token);
Assert.Equal(refreshedToken.ExpiresIn, TimeSpan.FromSeconds(expectedJsonToken.expires_in));
Assert.Equal(expectedJsonToken.access_token, refreshedToken.AccessToken);
Assert.Equal(expectedJsonToken.refresh_token, refreshedToken.RefreshToken);
Assert.Equal(TimeSpan.FromSeconds(expectedJsonToken.expires_in), refreshedToken.ExpiresIn);
}

[Fact]
Expand Down
20 changes: 10 additions & 10 deletions projects/Unit/TestOAuth2ClientCredentialsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void ShouldRequestTokenWhenGettingPasswordOrValidUntilForFirstTimeAccess(
{
IToken firstToken = newToken("the_access_token", "the_refresh_token", TimeSpan.FromSeconds(1));
_oAuth2Client.Setup(p => p.RequestToken()).Returns(firstToken);
Assert.Equal(firstToken.AccessToken, _provider.Password);
Assert.Equal(firstToken.ExpiresIn, _provider.ValidUntil.Value);
Assert.Equal(_provider.Password, firstToken.AccessToken);
Assert.Equal(_provider.ValidUntil.Value, firstToken.ExpiresIn);
}

[Fact]
Expand All @@ -78,15 +78,15 @@ public void ShouldRefreshTokenUsingRefreshTokenWhenAvailable()
IToken refreshedToken = newToken("the_access_token2", "the_refresh_token_2", TimeSpan.FromSeconds(60));
_oAuth2Client.Setup(p => p.RequestToken()).Returns(firstToken);
_provider.Refresh();
Assert.Equal(firstToken.AccessToken, _provider.Password);
Assert.Equal(firstToken.ExpiresIn, _provider.ValidUntil.Value);
Assert.Equal(_provider.Password, firstToken.AccessToken);
Assert.Equal(_provider.ValidUntil.Value, firstToken.ExpiresIn);
_oAuth2Client.Reset();
System.Threading.Thread.Sleep(1000);

_oAuth2Client.Setup(p => p.RefreshToken(firstToken)).Returns(refreshedToken);
_provider.Refresh();
Assert.Equal(refreshedToken.AccessToken, _provider.Password);
Assert.Equal(refreshedToken.ExpiresIn, _provider.ValidUntil.Value);
Assert.Equal(_provider.Password, refreshedToken.AccessToken);
Assert.Equal(_provider.ValidUntil.Value, refreshedToken.ExpiresIn);

}

Expand All @@ -99,12 +99,12 @@ public void ShouldRequestTokenWhenRefreshTokenNotAvailable()
.Returns(firstToken)
.Returns(refreshedToken);
_provider.Refresh();
Assert.Equal(firstToken.AccessToken, _provider.Password);
Assert.Equal(firstToken.ExpiresIn, _provider.ValidUntil.Value);
Assert.Equal(_provider.Password, firstToken.AccessToken);
Assert.Equal(_provider.ValidUntil.Value, firstToken.ExpiresIn);

_provider.Refresh();
Assert.Equal(refreshedToken.AccessToken, _provider.Password);
Assert.Equal(refreshedToken.ExpiresIn, _provider.ValidUntil.Value);
Assert.Equal(_provider.Password, refreshedToken.AccessToken);
Assert.Equal(_provider.ValidUntil.Value, refreshedToken.ExpiresIn);
Mock.Verify(_oAuth2Client);
}

Expand Down

0 comments on commit b01f75c

Please sign in to comment.