Unit test code fails after package updated with breaking changes

JsChicago 1 Reputation point
2020-10-11T19:16:45.807+00:00

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);
        }
    }
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
336 questions
{count} votes