public void AuthentificateByDevice(string username)
{
    Debug.Log("Authenticating by Device ID...");
    new DeviceAuthenticationRequest().SetDisplayName(username).Send((response) =>
    {
        if (!response.HasErrors)
        {
            Debug.Log("Device Authenticated...");
            Authentificated = true;
            _userID = response.UserId;
        }
        else
        {
            Debug.LogError("Error Authenticating Device... " + response.Errors.JSON);
        }
    });
}

I wrote a method for authentificating my user in gamesparks and to get his userId. Now I want to write a unit test for this function using NSubstitute.

string name = "Fred";
string userId = "";
var gameSparks = Substitute.For<GameSparksManager>();
gameSparks.When(x => x.AuthentificateByDevice(name)).Do(x => userId == "d311e035-d001-4a50-9afd-3611992049c1");

It shows an error: The type ValueTask that defined in an assembly that is not referred. You must add a reference to assembly 'System.Threading.Tasks.Extension...'. How can I fix this problem?

0 Answers