public async Task ValidateBewit_WithAlteredPayload_ShouldThrow()
        {
            //Arrange
            ICryptographyService cryptoService =
                MockHelper.GetMockedCrpytoService <Foo>();
            var nonceRepository = new DefaultNonceRepository();
            var provider        =
                new BewitTokenValidatorAccessor <Foo>(
                    cryptoService, new MockHelper.MockedVariablesProvider(), nonceRepository);

            var bewit = new Bewit <Foo>(
                "724e7acc-be57-49a1-8195-46a03c6271c6",
                new DateTime(2017, 1, 1, 1, 2, 1, 1, DateTimeKind.Utc),
                new Foo
            {
                Bar = 2
            },
                "724e7acc-be57-49a1-8195-46a03c6271c6__2017-01-01T01:02:01.0010000Z__{\"Bar\":1}");
            await nonceRepository.InsertOneAsync(bewit, default);

            //Act
            Func <Task> validateBewit = async() =>
                                        await provider.InvokeValidateBewitAsync(bewit,
                                                                                CancellationToken.None);

            //Assert
            await validateBewit.Should().ThrowAsync <BewitInvalidException>();
        }
        public async Task ValidateBewit_WithPayload_ShouldGenerateBewit()
        {
            //Arrange
            ICryptographyService cryptoService =
                MockHelper.GetMockedCrpytoService <Foo>();
            var nonceRepository = new DefaultNonceRepository();
            var provider        =
                new BewitTokenValidatorAccessor <Foo>(
                    cryptoService, new MockHelper.MockedVariablesProvider(), nonceRepository);
            var payload = new Foo
            {
                Bar = 1
            };

            var bewit = new Bewit <Foo>(
                "724e7acc-be57-49a1-8195-46a03c6271c6",
                new DateTime(2017, 1, 1, 1, 2, 1, 1, DateTimeKind.Utc),
                payload,
                "724e7acc-be57-49a1-8195-46a03c6271c6__2017-01-01T01:02:01.0010000Z__{\"Bar\":1}");
            await nonceRepository.InsertOneAsync(bewit, default);

            //Act
            Bewit <Foo> bewit2 = await provider.InvokeValidateBewitAsync(bewit, CancellationToken.None);

            //Assert
            bewit2.Should().Be(bewit);
        }