Ejemplo n.º 1
0
        public async Task CreateAsync_should_add_entity_id_to_parent()
        {
            using var store = new RavenDbTestDriverWrapper().GetDocumentStore();

            using var s1 = store.OpenAsyncSession();
            await s1.StoreAsync(new Entity.ExternalProvider
            {
                Id = "test",
            }, $"{nameof(Entity.ExternalProvider).ToLowerInvariant()}/test");

            await s1.SaveChangesAsync();

            var loggerMock = new Mock <ILogger <AdminStore <Entity.ExternalClaimTransformation> > >();

            using var session = store.OpenAsyncSession();

            var sut = CreateSut(session, loggerMock.Object);

            var entity = new Entity.ExternalClaimTransformation
            {
                Id     = Guid.NewGuid().ToString(),
                Scheme = "test"
            };

            await sut.CreateAsync(entity);

            using var s2 = store.OpenAsyncSession();
            var parent = await s2.LoadAsync <Entity.ExternalProvider>($"{nameof(Entity.ExternalProvider).ToLowerInvariant()}/test");

            var collection = GetCollection(parent);

            Assert.Contains(collection, i => i.Id == $"{typeof(Entity.ExternalClaimTransformation).Name.ToLowerInvariant()}/{entity.Id}");
        }
Ejemplo n.º 2
0
        public async Task DeleteAsync_should_not_throw_when_parent_not_exists()
        {
            using var store = new RavenDbTestDriverWrapper().GetDocumentStore();

            var entity = new Entity.ExternalClaimTransformation
            {
                Id     = Guid.NewGuid().ToString(),
                Scheme = "test"
            };

            using var s1 = store.OpenAsyncSession();
            await s1.StoreAsync(entity, $"{typeof(Entity.ExternalClaimTransformation).Name.ToLowerInvariant()}/{entity.Id}");

            await s1.SaveChangesAsync();

            var loggerMock = new Mock <ILogger <AdminStore <Entity.ExternalClaimTransformation> > >();

            using var session = store.OpenAsyncSession();

            var sut = CreateSut(session, loggerMock.Object);


            await sut.DeleteAsync(entity.Id);

            using var s2 = store.OpenAsyncSession();
            Assert.Null(await s2.LoadAsync <Entity.ExternalClaimTransformation>($"{typeof(Entity.ExternalClaimTransformation).Name.ToLowerInvariant()}/{entity.Id}"));
        }
Ejemplo n.º 3
0
        public async Task CreateAsync_should_throw_when_parent_not_exists()
        {
            using var store = new RavenDbTestDriverWrapper().GetDocumentStore();

            var loggerMock = new Mock <ILogger <AdminStore <Entity.ExternalClaimTransformation> > >();

            using var session = store.OpenAsyncSession();

            var sut = CreateSut(session, loggerMock.Object);

            var entity = new Entity.ExternalClaimTransformation
            {
                Id     = Guid.NewGuid().ToString(),
                Scheme = "test"
            };

            await Assert.ThrowsAsync <InvalidOperationException>(() => sut.CreateAsync(entity));
        }