Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Unit tests failing #6709


User avatar
0
MellowoodMedical created

Hi, all unit tests shipped with aspnet zero project are failing with following exception:

"format of the initialization string does not conform to specification starting at index 0"

Please suggest.

thanks, Gaurav


12 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, can you share the full stacktrace of the exception?

    Also,

    • What is your product version?
    • What is your product type (Angular or MVC)?
    • What is product framework type (.net framework or .net core)?
  • User Avatar
    0
    MellowoodMedical created

    Hi,

    Please find below my comments in bold:

    What is your product version? Regular What is your product type (Angular or MVC)? Angular What is product framework type (.net framework or .net core)? .net core 2.2


    StackTrace: System.ArgumentException : Format of the initialization string does not conform to specification starting at index 0. Stack trace: at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary2 parsetable, String connectionString, Boolean buildChain, Dictionary2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary2 synonyms) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at lambda_method(Closure ) at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable1.GetEnumerator() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable1 results, QueryContext queryContext, IList1 entityTrackingInfos, IList1 entityAccessors)+MoveNext() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_11.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate) at PatientPortal.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/DefaultEditionCreator.cs:line 26 at PatientPortal.Migrations.Seed.Host.DefaultEditionCreator.Create() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/DefaultEditionCreator.cs:line 21 at PatientPortal.Migrations.Seed.Host.InitialHostDbBuilder.Create() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/Host/InitialHostDbBuilder.cs:line 16 at PatientPortal.Migrations.Seed.SeedHelper.SeedHostDb(PatientPortalDbContext context) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 26 at PatientPortal.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action1 contextAction) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 42 at PatientPortal.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/Migrations/Seed/SeedHelper.cs:line 18 at PatientPortal.EntityFrameworkCore.PatientPortalEntityFrameworkCoreModule.PostInitialize() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/src/PatientPortal.EntityFrameworkCore/EntityFrameworkCore/PatientPortalEntityFrameworkCoreModule.cs:line 83 at System.Collections.Generic.List1.ForEach(Action1 action) at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 155 at Abp.TestBase.AbpIntegratedTestBase`1.InitializeAbp() in D:\Github\aspnetboilerplate\src\Abp.TestBase\TestBase\AbpIntegratedTestBase.cs:line 53 at PatientPortal.Tests.AppTestBase..ctor() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/test/PatientPortal.Tests/AppTestBase.cs:line 27 at PatientPortal.Tests.Auditing.AuditLogAppService_Tests..ctor() in /Users/gaurav/Documents/Projects/Ideas/PatientPortalV2/test/PatientPortal.Tests/Auditing/AuditLogAppService_Tests.cs:line 21


  • User Avatar
    0
    aaron created
    Support Team

    Your connection string is invalid.

  • User Avatar
    0
    MellowoodMedical created

    HI,

    Thats right, its invalid connection string error but its failing for in-memory database only for unit test project ("Data Source=":memory:".) We haven't changed any shipped code and only trying to run all unit tests thats come with the project. Can you suggest.

  • User Avatar
    0
    maliming created
    Support Team

    @MellowoodMedical Can you share your project to: [email protected]?

  • User Avatar
    0
    MellowoodMedical created

    Hi,

    Shared project at above mentioned email address.

    Thanks, Gaurav Singh

  • User Avatar
    0
    maliming created
    Support Team

    I can't download your project, can you send it directly via the gmail attachment?

  • User Avatar
    0
    maliming created
    Support Team

    @MellowoodMedical

    I have downloaded and tested your project.

    set abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true; to solve your problem.

    public PatientPortalTestModule(PatientPortalEntityFrameworkCoreModule abpZeroTemplateEntityFrameworkCoreModule)
    {
    	abpZeroTemplateEntityFrameworkCoreModule.SkipDbContextRegistration = true;
    }
    
    

  • User Avatar
    0
    MellowoodMedical created

    Thanks, tests are running now.

  • User Avatar
    0
    gpicazo created

    Hi,

    I am also using the regular aspnet core (2.2)/angular solution v6.9.1 and also have most of my unit tests failing -- most with the below error. Note that I have disabled multi-tenancy.

    Any help would be appreciated.

    Oh, and also, why was the above change needed for @MellowoodMedical's solution?

    Thanks, Genaro


    Test Name: Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests.Should_Get_OrganizationUnits Test FullName: Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests.Should_Get_OrganizationUnits Test Source: C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.GraphQL.Tests\OrganizationUnits\OrganizationUnitQuery_Tests.cs : line 11 Test Outcome: Failed Test Duration: 0:00:00.001

    Result StackTrace: at Cssc.LessToRemember.Migrations.Seed.Host.DefaultSettingsCreator.Create() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\Host\DefaultSettingsCreator.cs:line 27 at Cssc.LessToRemember.Migrations.Seed.Host.InitialHostDbBuilder.Create() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\Host\InitialHostDbBuilder.cs:line 19 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.SeedHostDb(LessToRememberDbContext context) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 26 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action1 contextAction) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 42 at Cssc.LessToRemember.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 18 at Cssc.LessToRemember.EntityFrameworkCore.LessToRememberEntityFrameworkCoreModule.PostInitialize() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\src\Cssc.LessToRemember.EntityFrameworkCore\EntityFrameworkCore\LessToRememberEntityFrameworkCoreModule.cs:line 61 at System.Collections.Generic.List1.ForEach(Action1 action) at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 155 at Abp.TestBase.AbpIntegratedTestBase1.InitializeAbp() in D:\Github\aspnetboilerplate\src\Abp.TestBase\TestBase\AbpIntegratedTestBase.cs:line 53 at Cssc.LessToRemember.Test.Base.AppTestBase1..ctor() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.Test.Base\AppTestBase.cs:line 30 at Cssc.LessToRemember.GraphQL.Tests.GraphQLTestBase2..ctor() in C:\Dev\CompositeStack\Cssc.LessToRemember.Api\test\Cssc.LessToRemember.GraphQL.Tests\GraphQLTestBase.cs:line 36 at Cssc.LessToRemember.GraphQL.Tests.GraphQLTestBase`1..ctor() at Cssc.LessToRemember.GraphQL.Tests.OrganizationUnits.OrganizationUnitQuery_Tests..ctor() Result Message: System.NullReferenceException : Object reference not set to an instance of an object.

  • User Avatar
    0
    aaron created
    Support Team

    Note to maintainers regarding the error faced by @gpicazo:

    InitialHostDbBuilder.Create is called before DefaultTenantBuilder.Create in SeedHelper.cs, so defaultTenant is null.

  • User Avatar
    0
    gpicazo created

    @aaron - thanks, that worked