示例#1
0
        public async Task CreateToken_ValidCredentials_ValidTokenReturned()
        {
            //arrange
            var authenticationClient = new AuthenticationEndpoint(_baseConfiguration, _authenticationConfiguration, GetDefaultSezzleHttpClient());

            //act
            var resp = await authenticationClient.CreateTokenAsync();

            //assert
            Assert.AreNotEqual(0, resp.Token.Length);
            Assert.Greater(resp.ExpirationDate, DateTime.Now);
        }
示例#2
0
        public void CreateToken_BadSezzleUrlEndpoint_ExceptionThrown()
        {
            Func <Task> act = async() =>
            {
                //arrange
                _baseConfiguration.ApiUrl += "aaaaa/";
                var authenticationClient = new AuthenticationEndpoint(_baseConfiguration, _authenticationConfiguration,
                                                                      GetDefaultSezzleHttpClient());

                //act
                var resp = await authenticationClient.CreateTokenAsync();
            };

            //assert
            act.Should().Throw <SezzleErrorResponseException>();
        }
示例#3
0
        public void CreateToken_InvalidCredentials_BadPrivateKey_TargetedExceptionThrown()
        {
            Func <Task> act = async() =>
            {
                //arrange
                _authenticationConfiguration.ApiPrivateKey += "bad";
                var authenticationClient = new AuthenticationEndpoint(_baseConfiguration, _authenticationConfiguration,
                                                                      GetDefaultSezzleHttpClient());

                //act
                var resp = await authenticationClient.CreateTokenAsync();
            };

            //assert
            act.Should().Throw <SezzleErrorResponseException>();
        }
示例#4
0
        public void CreateToken_ValidUrlThatIsNotSezzle_KnownExceptionThrown()
        {
            Func <Task> act = async() =>
            {
                //arrange
                _baseConfiguration.ApiUrl = "http://www.google.com";
                var authenticationClient = new AuthenticationEndpoint(_baseConfiguration, _authenticationConfiguration,
                                                                      GetDefaultSezzleHttpClient());

                //act
                var resp = await authenticationClient.CreateTokenAsync();
            };

            //assert
            act.Should().Throw <SezzleErrorResponseException>();
        }
示例#5
0
        public void CreateToken_BlankUrl_ExceptionThrown()
        {
            Func <Task> act = async() =>
            {
                //arrange
                _baseConfiguration.ApiUrl = string.Empty;
                var authenticationClient = new AuthenticationEndpoint(_baseConfiguration, _authenticationConfiguration,
                                                                      GetDefaultSezzleHttpClient());

                //act
                var resp = await authenticationClient.CreateTokenAsync();
            };

            //assert
            //todo: get these other unit tests working.
            act.Should().Throw <System.UriFormatException>();
        }