Activities of "agilmore"

  • ABP Framework version: v4.3.2
  • UI type: Blazor
  • DB provider: EF Core

I have the following test method in a test class that derives from AppDomainTestBase

The Column class is managed through the EntityInstance AggregateRoot.

The EntityInstance class has the following AddColumn method:

The AppEfCoreQueryableExtensions class includes:

And the EfCoreEntityInstanceRepository class contains:

So why doesn't ...

return the entity.Columns collection ?

Is it because of Unit of Work ?

By the way I was blocked from submitting this issue with the code embedded as text.

Ok, Thanks very much for your help.

Ok.

I made the change and it worked.

Just to clarify.

  1. I only need to add the EfCoreQuerableExtensions because EF is using SQLite in Test mode ?
  2. Or, EfCoreQuerableExtensions need to be configured for SQL Server in Production as well ?

Thanks - Adam

I haven't.

The Abp framework EF documentations says GetAsync will include details as default. Does that not work for Sqlite? Or does it have to be configuredevery time? That would be a good addition to your documentation.

Hi.

Thanks, that fixed the issue.

A supplementary question, does the SQlite EF Core Context used by the test framework support the IncludeDetails=true.

In my code above foreach(var templateBranch in template.Branches), Branches returns null.

Branches are added in a seeding class, which worked for SQL Server.

When I run the Should_CopyTemplate_Test() test case below, the reference to CurrentTenant in the method it calls is returning NullReferenceException, as if the ICurrentTenant is not being injected.

I have this test set up:

    {

        private ISltnRepository _sltnRepository;
        private ICurrentTenant _currentTenant;

        public SltnManager_Tests()
        {
            _sltnRepository = GetRequiredService<ISltnRepository>();
            _currentTenant = GetRequiredService<ICurrentTenant>();
        }

        [Fact]
        public async Task Should_CopyTemplate_Test()
        {
            // Arrange
            var sltnManager = new SltnManager(_sltnRepository);

            // Act
            Guid sltnId = Guid.Parse("00000000-14ba-4f0f-8417-c2f312768aea");
            var sltn = await sltnManager.CopyTemplate(sltnId);

            //Assert
            sltn.Name.ShouldBe("");
        }
    }

Testing this method:

        public async Task<Sltn> CopyTemplate(Guid templateId)
     {
         // Get the template solution from the host tenant
         Sltn template;
         using (CurrentTenant.Change(null))
         {
             template = await _sltnRepository.GetAsync(templateId);
         }
         // set a branches list from the template
         List<Branch> branches = new List<Branch>();
         foreach(var templateBranch in template.Branches)
         {
             branches.Add(new Branch(GuidGenerator.Create(), templateBranch.Name, templateBranch.Description, templateBranch.AppUserId, templateBranch.ParentBranchId));
         }
         
         //create a new solution for the tenant from the template
         var sltn = new Sltn(GuidGenerator.Create(), template.Name, template.Description, template.DisplayOrder, branches);
         await _sltnRepository.InsertAsync(sltn);
         return sltn;
     }

However CurrentTenant.Change is returning NullReferenceException on CurrentTenant.

Showing 21 to 26 of 26 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11