public void WHEN_token_is_null_SHOULD_throw_ArgumentNullException()
        {
            //Arrange
            SharedWishListToken param = null;

            //Act
            var ex = Assert.Throws <ArgumentNullException>(() => SharedWishListTokenizer.GenerateToken(param));

            //Assert
            ex.Should().NotBeNull();
            ex.ParamName.Should().NotBeNullOrWhiteSpace();
        }
        public void WHEN_token_ok_SHOULD_return_encrypted_token()
        {
            //Arrange
            SharedWishListToken param = new SharedWishListToken
            {
                CustomerId = Guid.NewGuid(),
                Scope      = GetRandom.String(6)
            };

            //Act
            var token = SharedWishListTokenizer.GenerateToken(param);

            //Assert
            token.Should().NotBeNullOrWhiteSpace();
            token.Should().NotContainEquivalentOf(param.CustomerId.ToString());
            token.Should().NotContainEquivalentOf(param.Scope);
        }
        public void WHEN_CustomerId_is_invalid_SHOULD_throw_ArgumentNullException()
        {
            //Arrange
            SharedWishListToken param = new SharedWishListToken
            {
                CustomerId = Guid.Empty,
                Scope      = GetRandom.String(6)
            };

            //Act
            var ex = Assert.Throws <ArgumentException>(() => SharedWishListTokenizer.GenerateToken(param));

            //Assert
            ex.Should().NotBeNull();
            ex.ParamName.Should().NotBeNullOrWhiteSpace();
            ex.Message.Should().NotBeNullOrWhiteSpace();
        }
Example #4
0
        public void WHEN_token_is_valid_SHOULD_return_dto(string scope)
        {
            //Arrange
            var param = new SharedWishListToken
            {
                CustomerId = Guid.NewGuid(),
                Scope      = scope
            };

            var token = SharedWishListTokenizer.GenerateToken(param);

            //Act
            var dto = SharedWishListTokenizer.DecryptToken(token);

            //Assert
            dto.Should().NotBeNull();
            dto.CustomerId.Should().Be(param.CustomerId);
            dto.Scope.Should().Be(param.Scope);
        }