Example #1
0
        public async Task ThrowExceptionWhenNoTokenStoredTest()
        {
            // Arrange
            var securityTokenService = new SecurityTokenService(context);

            // Act
            Func <Task <IList <string> > > act = async() => await securityTokenService.GetSavedData(Guid.NewGuid(), string.Empty);

            // Assert
            await act.Should().ThrowAsync <InvalidOperationException>().WithMessage("Sequence contains no elements");
        }
Example #2
0
        public async Task ThrowExceptionWhenTokenDoesNotMatchTest()
        {
            // Arrange
            var userId = Guid.NewGuid();
            var securityTokenService = new SecurityTokenService(context);
            await securityTokenService.SaveDataWithTokenAsync(
                new List <string>
            {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            },
                userId);

            // Act
            Func <Task <IList <string> > > act = async() => await securityTokenService.GetSavedData(userId, string.Empty);

            // Assert
            await act.Should().ThrowAsync <GeneratorException>().WithMessage("User Token doesn't match stored one");
        }