public async Task migration_from_v3_to_v4_should_not_result_in_schema_difference() { // setup/simulate a full text index as in v3 StoreOptions(_ => { _.Schema.For <User>().FullTextIndex(); }); await theStore.Schema.ApplyAllConfiguredChangesToDatabaseAsync(); // drop and recreate index with a sql statement not containing `::regconfig` await using (var conn = new NpgsqlConnection(ConnectionSource.ConnectionString)) { await conn.OpenAsync(); await conn.CreateCommand("DROP INDEX if exists fulltext.mt_doc_user_idx_fts") .ExecuteNonQueryAsync(); await conn.CreateCommand("CREATE INDEX mt_doc_user_idx_fts ON fulltext.mt_doc_user USING gin (( to_tsvector('english', data) ))") .ExecuteNonQueryAsync(); } // create another store and check if there is no schema difference var store2 = DocumentStore.For(_ => { _.Connection(ConnectionSource.ConnectionString); _.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; _.DatabaseSchemaName = "fulltext"; _.Schema.For <User>().FullTextIndex(); }); await Should.NotThrowAsync(async() => await store2.Schema.AssertDatabaseMatchesConfigurationAsync()); }
public async Task can_migrate_table_with_index_include_clause_from_v3_to_v4() { StoreOptions(opts => { opts.Schema.For <Bug1982.TestDoc>() .Duplicate(x => x.FirstColumn) .Duplicate(x => x.SecondColumn); }); await theStore.Schema.ApplyAllConfiguredChangesToDatabaseAsync(AutoCreate.CreateOrUpdate); var theMapping = DocumentMapping.For <Bug1982.TestDoc>(SchemaName); // Add a custom index with include clause await using (var conn = new NpgsqlConnection(ConnectionSource.ConnectionString)) { await conn.OpenAsync(); await conn .CreateCommand($"CREATE INDEX idx_custom_with_include_clause ON {theMapping.TableName.QualifiedName} USING btree (first_column) INCLUDE (second_column);") .ExecuteNonQueryAsync(); } await Should.NotThrowAsync(async() => await theStore.Schema.ApplyAllConfiguredChangesToDatabaseAsync(AutoCreate.CreateOrUpdate)); }
public async Task ShouldNotThrowEntityNotFoundExceptionWhileDeletingAlreadyDeletedAsync() { await _service.DeleteAsync(_data.Content_2_Id); await Should.NotThrowAsync(async() => await _service.DeleteAsync(_data.Content_2_Id)); }
public async Task ProcessRegistrantInvite_TwoSameRegistrant_FirstIsInvalid() { var dp = Services.GetRequiredService <IDataProtectionProvider>().CreateProtector(nameof(InviteRegistrantCommand)).ToTimeLimitedDataProtector(); var registrant = CreateNewTestRegistrantProfile(); var userId = TestHelper.GenerateNewUniqueId(TestData.TestPrefix); var registrantId = await manager.Handle(new SaveRegistrantCommand { Profile = registrant }); var firstInviteId = dp.Protect(await manager.Handle(new InviteRegistrantCommand { RegistrantId = registrantId, Email = $"{TestData.TestPrefix}[email protected]", RequestingUserId = null })); var secondInviteId = dp.Protect(await manager.Handle(new InviteRegistrantCommand { RegistrantId = registrantId, Email = $"{TestData.TestPrefix}[email protected]", RequestingUserId = null })); await Should.ThrowAsync <NotFoundException>(manager.Handle(new ProcessRegistrantInviteCommand { InviteId = firstInviteId, LoggedInUserId = userId })); await Should.NotThrowAsync(manager.Handle(new ProcessRegistrantInviteCommand { InviteId = secondInviteId, LoggedInUserId = userId })); }
public async Task space_in_table_name_does_not_cause_exception_on_update() { StoreOptions(_ => { _.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate; _.Storage.Add(new spaceInNameSchema()); }); await Should.NotThrowAsync(async() => { await theStore.Schema.ApplyAllConfiguredChangesToDatabaseAsync(); await theStore.Schema.AssertDatabaseMatchesConfigurationAsync(); }); }
public async Task ShouldUpdateContentAsync() { var dto = new UpdatePageContentInputDto { Content = "my-new-content" }; await Should.NotThrowAsync(async() => await _pageAdminAppService.UpdatePageContentAsync(_data.Page_1_Id, dto)); var content = await _contentRepository.GetAsync(nameof(Page), _data.Page_1_Id.ToString()); content.Value.ShouldBe(dto.Content); }
public async Task ShouldCreateAsync() { var dto = new CreatePageInputDto { Title = "test", Slug = "test-url" }; await Should.NotThrowAsync(async() => await _pageAdminAppService.CreateAsync(dto)); var page = await _pageRepository.GetBySlugAsync(dto.Slug); page.Title.ShouldBe(dto.Title); }
public async Task can_apply_schema_changes_with_create_options_independent_of_store_options_auto_create() { StoreOptions(_ => { _.DatabaseSchemaName = "apply_all_config_changes_to_db_1"; _.Schema.For <User>(); _.AutoCreateSchemaObjects = AutoCreate.None; }); await Should.NotThrowAsync(async() => { await theStore.Schema.ApplyAllConfiguredChangesToDatabase(AutoCreate.All); await theStore.Schema.AssertDatabaseMatchesConfiguration(); }); }
public async Task Should_Create_A_Valid_Author() { await WithUnitOfWorkAsync(async() => { await Should.NotThrowAsync(async() => { var input = new CreateAuthorInput { Name = "张家老三", Description = "中国内地不知名网络小说作家" }; await _authorAppService.CreateAsync(input); }); }); }
public async Task ShouldCreateWithContentAsync() { var dto = new CreatePageWithContentInputDto { Title = "test", Url = "test-url", Content = "my-test-content" }; await Should.NotThrowAsync(async() => await _pageAdminAppService.CreatePageWithContentAsync(dto)); var page = await _pageRepository.GetByUrlAsync(dto.Url); var content = await _contentRepository.GetAsync(nameof(Page), page.Id.ToString()); content.Value.ShouldBe(dto.Content); }
public async Task ShouldUpdatePageAsync() { var dto = new UpdatePageInputDto { Title = _data.Page_1_Title + "++", Slug = _data.Page_1_Slug + "test" }; await Should.NotThrowAsync(async() => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id); updatedPage.Title.ShouldNotBe(_data.Page_1_Title); updatedPage.Title.ShouldBe(dto.Title); updatedPage.Slug.ShouldNotBe(_data.Page_1_Slug); updatedPage.Slug.ShouldBe(dto.Slug); }
public async Task Should_Create_Sku() { var product1 = await ProductRepository.GetAsync(ProductsTestData.Product1Id); var attributeOptionIds = new[] { ProductsTestData.Product1Attribute1Option4Id, ProductsTestData.Product1Attribute2Option2Id }; await Should.NotThrowAsync(async() => { await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(attributeOptionIds)); }); var serializedAttributeOptionIds = await AttributeOptionIdsSerializer.SerializeAsync(attributeOptionIds); product1.ProductSkus.Count(x => x.SerializedAttributeOptionIds == serializedAttributeOptionIds).ShouldBe(1); }
public async Task can_auto_update_event_store_schema_changes() { using var store1 = Store(AutoCreate.All); await store1.Schema.ApplyAllConfiguredChangesToDatabase(); SimulateEventStoreV3Schema(); // create another store and check if the schema can be be auto updated using var store2 = Store(AutoCreate.CreateOrUpdate); await Should.ThrowAsync <SchemaValidationException>(async() => { await store2.Schema.AssertDatabaseMatchesConfiguration(); }); await Should.NotThrowAsync(async() => { await store2.Schema.ApplyAllConfiguredChangesToDatabase(); await store2.Schema.AssertDatabaseMatchesConfiguration(); }); }
public async void Refresh() { var cache = ServiceProvider.GetRequiredService <IDistributedCache <Entity> >(); var entity = new Entity { Id = 1, Name = "Vincent" }; DistributedCacheEntryOptions options = new DistributedCacheEntryOptions(); options.SlidingExpiration = new TimeSpan(0, 0, 0, 1); cache.Set("3", entity, options); Should.NotThrow(() => { cache.Refresh("3"); }); await Should.NotThrowAsync(cache.RefreshAsync("3")); }
public async Task ShouldUpdatePageAsync() { var dto = new UpdatePageInputDto { Title = _data.Page_1_Title + "++", Description = "new description", Url = _data.Page_1_Url + "test" }; await Should.NotThrowAsync(async() => await _pageAdminAppService.UpdatePageAsync(_data.Page_1_Id, dto)); var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id); updatedPage.Title.ShouldNotBe(_data.Page_1_Title); updatedPage.Title.ShouldBe(dto.Title); updatedPage.Url.ShouldNotBe(_data.Page_1_Url); updatedPage.Url.ShouldBe(dto.Url); updatedPage.Description.ShouldNotBe(_data.Page_1_Description); updatedPage.Description.ShouldBe(dto.Description); }
public async void Set_Get_Remove_Cache_ItemAsync() { var cache = ServiceProvider.GetRequiredService <IDistributedCache <Entity> >(); var entity = new Entity { Id = 1, Name = "Vincent" }; await Should.NotThrowAsync(cache.SetAsync("1", entity)); var cachedEntity = await cache.GetAsync("1"); cachedEntity.Id.ShouldBe(entity.Id); cachedEntity.Name.ShouldBe(entity.Name); await Should.NotThrowAsync(cache.RemoveAsync("1")); var shouldNull = await cache.GetAsync("1"); shouldNull.ShouldBeNull(); }
public async Task CanHandleConcurrentPdfGenerationRequests() { Func <string> template = () => $@"<!DOCTYPE html> <html> <head> </head> <body> <header> <h1>Header</h1> </header> <main> <p>{DateTime.Now}</p> </main> </body> </html>"; using var generator = services.GetRequiredService <IPdfGenerator>(); await Enumerable.Range(0, 100).ForEachAsync(10, async i => { await Should.NotThrowAsync(generator.Generate(template())); }); }
public async Task ShouldGetByUrlAsync() { await Should.NotThrowAsync(async() => await _pageAppService.GetByUrlAsync(_data.Page_1_Url)); }