Exemplo n.º 1
0
        public async Task StoreReferenceTokenAsync_should_update_entity()
        {
            using var store = new RavenDbTestDriverWrapper().GetDocumentStore();
            var serializer = new PersistentGrantSerializer();
            var loggerMock = new Mock <ILogger <ReferenceTokenStore> >();

            var token = new Token
            {
                ClientId = "test"
            };

            using var s1 = store.OpenAsyncSession();
            await s1.StoreAsync(new Entity.ReferenceToken
            {
                Id       = "test",
                ClientId = "test",
                Data     = serializer.Serialize(token)
            }, $"{nameof(Entity.ReferenceToken)}/test");

            await s1.SaveChangesAsync();

            using var session = store.OpenAsyncSession();
            var sut = new ReferenceTokenStore(new ScopedAsynDocumentcSession(session), serializer, loggerMock.Object);

            var code = await sut.StoreReferenceTokenAsync(token);

            Assert.Equal("test", code);
        }
Exemplo n.º 2
0
        public async Task StoreReferenceTokenAsync_should_create_entity()
        {
            using var store = new RavenDbTestDriverWrapper().GetDocumentStore();
            var serializer = new PersistentGrantSerializer();
            var loggerMock = new Mock <ILogger <ReferenceTokenStore> >();

            using var session = store.OpenAsyncSession();
            var sut = new ReferenceTokenStore(new ScopedAsynDocumentcSession(session), serializer, loggerMock.Object);

            var code = await sut.StoreReferenceTokenAsync(new Token
            {
                ClientId = "test"
            });

            using var s2 = store.OpenAsyncSession();

            var result = await s2.LoadAsync <Entity.ReferenceToken>($"{nameof(Entity.ReferenceToken)}/{code}");

            Assert.NotNull(result);
        }