- Template: app
- Created ABP Studio Version: 1.2.2
- Current ABP Studio Version: 1.2.2
- Tiered: Yes
- Multi-Tenancy: Yes
- UI Framework: blazor-webapp
- Theme: leptonx
- Theme Style: system
- Theme Menu Placement: side
- Run Install Libs: Yes
- Database Provider: mongodb
- Run Db Migrator: Yes
- Mobile Framework: none
- Public Website: Yes
- Social Login: Yes
- Include Tests: Yes
- Kubernetes Configuration: Yes
- Distributed Event Bus: rabbitmq
- Use Local References: No
- Optional Modules:
- GDPR
- FileManagement
- TextTemplateManagement
- LanguageManagement
- AuditLogging
- Chat
- OpenIddictAdmin
- Selected Languages: English, English (United Kingdom)
- Default Language: English
- Create Command: abp new AT1.Core -t app --tiered --ui-framework blazor-webapp --database-provider mongodb --theme leptonx --public-website --without-cms-kit --sample-crud-page --dont-run-bundling -chat -file-management
Using ABP Suite to generate an entity creates files with invalid refs:
MongoDB.Tests\MongoDB\Applications\Tickets\MongoDBTicketsAppServiceTests.cs MongoDB.Tests\MongoDB\Domains\Tickets\TicketRepositoryTests.cs MongoDB.Tests\MongoDB\MongoTestCollection.cs
'MongoTestCollection' does not contain a definition for 'CollectionDefinitionName'
[CollectionDefinition(Name)] public class MongoTestCollection : ICollectionFixture<MongoDbFixture> { public const string Name = "MongoDB Collection"; }
We are reporting this as a bug. Please reset our alloted question count. Thanks!
5 Answer(s)
-
0
The issue you described is related to the test collection naming in the generated MongoDB test files. In the generated
MongoTestCollection
class, the constantName
is used for the collection definition, but the test classes are likely referencing a non-existentCollectionDefinitionName
constant, causing invalid references.The correct approach is to use the defined constant
Name
in your test classes, like this:
[Collection(MongoTestCollection.Name)] public class MongoDBTicketsAppServiceTests { // Test code here }
If your generated test classes reference
MongoTestCollection.CollectionDefinitionName
, you should replace it withMongoTestCollection.Name
to match the actual constant defined in theMongoTestCollection
class.This is a known pattern in ABP's MongoDB test template. You can refer to the official template for correct usage:
- https://github.com/abpframework/abp/tree/dev/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests
For more details on MongoDB test setup in ABP microservice projects, see:
- https://abp.io/docs/latest/guides/microservice-mongodb
- https://github.com/abpframework/abp/pull/3982
To summarize, update your test classes to use
MongoTestCollection.Name
instead ofCollectionDefinitionName
to resolve the invalid reference.
Sources:
- https://abp.io/docs/latest/guides/microservice-mongodb
- https://github.com/abpframework/abp/tree/dev/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests
- https://github.com/abpframework/abp/pull/3982
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
Yes we know. We are reporting that the ABP Studio Suite is generating the incorrect ref.
-
0
We are reporting this as a bug. Please reset our alloted question count. Thanks!
-
0
Also the github links do not reflect what ABP Suite is generating.
-
0
Hi @mike3077,
Thanks for your reporting. I created an issue for it and refunded your question credit.