/// <summary>
    /// Logs the given <paramref name="usr"/> in.
    /// </summary>
    /// <param name="usr">User to log in.</param>
    private void LoginUser(User usr)
    {
      var session = new LastUserSession();
      session.Username = usr.Username;
      session.Token = usr.Token;
      session.IsSubscriber = usr.IsSubscriber;

      if (MainViewModel.Client.Auth.LoadSession(session))
        ActiveUser = usr;
    }
Пример #2
0
        public virtual void Initialise()
        {
            var testApiKey = "59dd1140db864fd4a68ca820709eaf98";
            var testApiSecret = "fa45357dcd914671a22def63cbe79a46";
            var testUserSession = new LastUserSession
            {
                IsSubscriber = false,
                Token = "071a119a9aac4942b1b05328a5591f55",
                Username = "******"
            };

            MockAuth = new Mock<ILastAuth>();
            MockAuth.SetupGet(m => m.Authenticated).Returns(true);
            MockAuth.SetupGet(m => m.ApiKey).Returns(testApiKey);

            var stubAuth = new LastAuth(testApiKey, testApiSecret);
            stubAuth.LoadSession(testUserSession);
            MockAuth.Setup(m => m.GenerateMethodSignature(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>()))
                .Returns<string, Dictionary<string, string>>((method, parameters) => stubAuth.GenerateMethodSignature(method, parameters));

            FakeResponseHandler = new QueueFakeResponseHandler();
            Scrobbler = GetScrobbler();
        }