//[Test()]
        public void CreateOAuthUserNamePasswordClientAccessProfileExpectSuccess()
        {
            var mockSettings = new Mock <IApplicationSettingsRepository>();

            mockSettings.Setup(s => s.GetStringValue("ClientId")).Returns("EasilogMobileApp");
            mockSettings.Setup(s => s.GetStringValue("ClientSecret")).Returns("E4092008CB5C45718718828DE56B39F3");
            mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("http://192.168.1.114:29065"));
            //mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("https://easilog-api-dev.azurewebsites.net"));
            var mockLogger = new Mock <ILogger>();
            var client     = new OAuthUsernamePasswordAuthenticationClient(mockSettings.Object, mockLogger.Object, new HmacSha256HashingService());

            client.SetCredentials(new UserCredentials()
            {
                Username = "******", Password = "******"
            });
            client.BeginLoginAsync().WaitAndUnwrapException();
            Assert.AreEqual(client.CurrentConnectionStatus, ClientConnectionStatus.Connected);

            var httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("http://192.168.1.114:29065");
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", client.AccessToken);
            var result = httpClient.GetAsync("authentication/profile/current").Result;

            Assert.IsNotNull(result);
        }
        //[Test()]
        public void CreateOAuthUserNamePasswordClientThenRefreshExpectSuccess()
        {
            var mockSettings = new Mock <IApplicationSettingsRepository>();

            mockSettings.Setup(s => s.GetStringValue("ClientId")).Returns("EasilogMobileApp");
            mockSettings.Setup(s => s.GetStringValue("ClientSecret")).Returns("E4092008CB5C45718718828DE56B39F3");
            mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("http://192.168.1.114:29065"));
            var mockLogger = new Mock <ILogger>();
            var client     = new OAuthUsernamePasswordAuthenticationClient(mockSettings.Object, mockLogger.Object, new HmacSha256HashingService());

            client.SetCredentials(new UserCredentials()
            {
                Username = "******", Password = "******"
            });
            client.BeginLoginAsync().WaitAndUnwrapException();
            Assert.AreEqual(client.CurrentConnectionStatus, ClientConnectionStatus.Connected);
            var bearerToken   = client.AccessToken;
            var savedSettings = client.SaveAsync().Result;

            var refreshOnlyClient = new OAuthUsernamePasswordAuthenticationClient(mockSettings.Object, mockLogger.Object, new HmacSha256HashingService());

            refreshOnlyClient.LoadAsync(savedSettings).Wait();
            refreshOnlyClient.BeginLoginAsync().WaitAndUnwrapException();
            Assert.AreEqual(refreshOnlyClient.CurrentConnectionStatus, ClientConnectionStatus.Connected);
            var refreshedBearerToken = client.AccessToken;

            Assert.AreEqual(bearerToken, refreshedBearerToken);
        }
        //[Test()]
        public void CreateOAuthUserNamePasswordClientSetCredentialsKeepsRefreshTokenExpectSuccess()
        {
            var mockSettings = new Mock <IApplicationSettingsRepository>();

            mockSettings.Setup(s => s.GetStringValue("ClientId")).Returns("EasilogMobileApp");
            mockSettings.Setup(s => s.GetStringValue("ClientSecret")).Returns("E4092008CB5C45718718828DE56B39F3");
            //mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("http://192.168.1.114:29065"));
            mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("https://easilog-api-dev.azurewebsites.net"));
            var mockLogger = new Mock <ILogger>();
            var client     = new OAuthUsernamePasswordAuthenticationClient(mockSettings.Object, mockLogger.Object, new HmacSha256HashingService());

            client.SetCredentials(new UserCredentials()
            {
                Username = "******", Password = "******", RefreshToken = "xyz"
            });
            Assert.IsTrue(client.CanRefresh);
        }
        //[Test()]
        public void CreateOAuthUserNamePasswordClientExpectSuccess()
        {
            var mockSettings = new Mock <IApplicationSettingsRepository>();

            mockSettings.Setup(s => s.GetStringValue("ClientId")).Returns("EasilogMobileApp");
            mockSettings.Setup(s => s.GetStringValue("ClientSecret")).Returns("E4092008CB5C45718718828DE56B39F3");
            //mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("http://192.168.1.114:29065"));
            mockSettings.Setup(s => s.GetUrl("AuthorisationServiceUrl")).Returns(new Uri("https://easilog-api-dev.azurewebsites.net"));
            var mockLogger = new Mock <ILogger>();
            var client     = new OAuthUsernamePasswordAuthenticationClient(mockSettings.Object, mockLogger.Object, new HmacSha256HashingService());

            client.SetCredentials(new UserCredentials()
            {
                Username = "******", Password = "******"
            });
            client.BeginLoginAsync().WaitAndUnwrapException();
            Assert.AreEqual(client.CurrentConnectionStatus, ClientConnectionStatus.Connected);
        }