Unit test code fails after package updated with breaking changes
JsChicago
1
Reputation point
Trying to repair some old code and broke a unit test. Specifically the line that creates the new TokenResponse object as it appears there is no longer a constructor for this IdentityModel class that takes an argument (Line #6) . Any suggestions would be appreciated
I've tried Moq and FakeItEasy, but have not been able to create a TokenResponse with
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var testAccessToken = "TestToken";
var dictionary = new Dictionary<string, string>
{
{IdentityModel.OidcConstants.TokenResponse.AccessToken, testAccessToken }
};
var response = new TokenResponse(JsonConvert.SerializeObject(dictionary)); //THIS CONSTRUCTOR NO LONGER TAKES ANY ARGUMENTS
var results = GetClientCredentials(
A.Fake<ServiceConfiguration>(),
DateTime.MinValue,
response
);
var request = new HttpRequestMessage();
await results.ProcessHttpRequestAsync(request, new CancellationToken());
Assert.AreEqual("Bearer", request.Headers.Authorization.Scheme);
Assert.AreEqual(testAccessToken, request.Headers.Authorization.Parameter);
}
}
Sign in to answer