public void AcquireTokenShouldThrowServerConnectionException()
        {
            // arrange
            var postServiceMock = new Mock <IPostService>();

            postServiceMock.Setup(
                serv => serv.SendAndGetAnswer(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Throws(new Exception());

            IRemoteTokenService remoteTokenService = new RemoteTokenService(postServiceMock.Object);

            // act & assert
            Assert.Throws <ServerConnectionException>(
                () => remoteTokenService.AcquireToken("sample_login", "sample_password"));
        }
        public void AcquireTokenShouldReturnNotValidServerAnswerException()
        {
            // arrange
            var postServiceMock = new Mock <IPostService>();

            postServiceMock.Setup(
                serv => serv.SendAndGetAnswer(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns("actually not a valid answer");

            IRemoteTokenService remoteTokenService = new RemoteTokenService(postServiceMock.Object);

            // act & assert
            Assert.Throws <ServerNotValidAnswerException>(
                () => remoteTokenService.AcquireToken("sample_login", "sample_password"));
        }
        public void AcquireTokenShouldReturnSampleJwt()
        {
            // arrange
            var postServiceMock = new Mock <IPostService>();

            postServiceMock.Setup(
                serv => serv.SendAndGetAnswer(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns(new JsonObject
            {
                Result = JsonValues.Authenticated,
                Jwt    = "sample_jwt"
            }.ToJson());

            IRemoteTokenService remoteTokenService = new RemoteTokenService(postServiceMock.Object);
            // act
            var answer = remoteTokenService.AcquireToken("sample_login", "sample_password");

            // assert
            Assert.Equal("sample_jwt", answer);
        }