ASP Core Identity - Unit test In Memory Error

Thomas James

I am trying to unit test a project of mine which uses ASP identity (EF core) within VS2017.

The issue I have is when I'm creating my DB context using EF cores in memory it blows up with the following Error -

Message: System.IO.FileLoadException : Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I'm using the following nuget packages

  • Microsoft.AspNetCore.Identity.EntityFrameworkCore - 1.1.2
  • Microsoft.EntityFrameworkCore.InMemory - 1.1.2

Rest are default xunit packages you get when creating the project.

Any help would be greatly appreciated, spend many hours trying to work out whats going wrong :/

This is the Unit Test Code:

public class TestDbContext : IdentityDbContext<User>
{
    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options)
    {
    }
}

public class User : IdentityUser
{
}

[Fact]
public void Test1()
{
    var builder = new DbContextOptionsBuilder<TestDbContext>();

    builder.UseInMemoryDatabase();

    var context = new TestDbContext(builder.Options);
}
Kristoffer Jälén

Upgrading to latest version of Microsoft.NET.Test.Sdk solves the problem.

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to unit test with ILogger in ASP.NET Core

From Dev

Unit Test UserManager<IdentityUser> in asp.net core

From Dev

Error with German character in Asp.Net Core Identity

From Dev

ASP.NET MVC Unit Test Project Entity Framework error

From Dev

ASP.NET MVC Unit Test Project Entity Framework error

From Dev

OCMock unit test error

From Java

ASP Identity Core GeneratePasswordResetTokenAsync expired

From Dev

Unit testing using ASP.NET Identity

From Dev

Unit test with example Core Data

From Dev

Limit to single core for unit test

From Dev

How do you unit test an ASP.NET Core controller or model object?

From Java

how to unit test asp.net core application with constructor dependency injection

From Dev

How do you unit test ASP.NET Core MVC Controllers that return anonymous objects?

From Dev

How to Unit Test ASP.NET CORE controller with MSTEST and add Fakes

From Dev

How to mock an IFormFile for a unit/integration test in ASP.NET Core 1 MVC 6?

From Dev

How do you unit test ASP.NET Core Web Application (.Net Framework)?

From Dev

How do you unit test ASP.NET Core MVC Controllers that return anonymous objects?

From Dev

Create unit test for View() with a List in ASP.net core MVC application

From Java

Can we unit test memory allocation?

From Dev

Can we unit test memory allocation?

From Dev

Adding Claims to an ASP.Net Identity Core user fails with EF insert error

From Dev

AngularJS Unit Test Error dependence

From Dev

VSTS Unit test error message

From Dev

Asp.net Identity Integration Test

From Dev

Error in test method in mvc for routing unit test

From Dev

DocumentDb Identity Provider for ASP.NET Core

From Dev

ASP.NET Core Identity Settings Not Working

From Dev

Asp MVC Core Identity Email Confirmation

From Dev

User.Identity.GetUserId() Owin Moq unit test

Related Related

  1. 1

    How to unit test with ILogger in ASP.NET Core

  2. 2

    Unit Test UserManager<IdentityUser> in asp.net core

  3. 3

    Error with German character in Asp.Net Core Identity

  4. 4

    ASP.NET MVC Unit Test Project Entity Framework error

  5. 5

    ASP.NET MVC Unit Test Project Entity Framework error

  6. 6

    OCMock unit test error

  7. 7

    ASP Identity Core GeneratePasswordResetTokenAsync expired

  8. 8

    Unit testing using ASP.NET Identity

  9. 9

    Unit test with example Core Data

  10. 10

    Limit to single core for unit test

  11. 11

    How do you unit test an ASP.NET Core controller or model object?

  12. 12

    how to unit test asp.net core application with constructor dependency injection

  13. 13

    How do you unit test ASP.NET Core MVC Controllers that return anonymous objects?

  14. 14

    How to Unit Test ASP.NET CORE controller with MSTEST and add Fakes

  15. 15

    How to mock an IFormFile for a unit/integration test in ASP.NET Core 1 MVC 6?

  16. 16

    How do you unit test ASP.NET Core Web Application (.Net Framework)?

  17. 17

    How do you unit test ASP.NET Core MVC Controllers that return anonymous objects?

  18. 18

    Create unit test for View() with a List in ASP.net core MVC application

  19. 19

    Can we unit test memory allocation?

  20. 20

    Can we unit test memory allocation?

  21. 21

    Adding Claims to an ASP.Net Identity Core user fails with EF insert error

  22. 22

    AngularJS Unit Test Error dependence

  23. 23

    VSTS Unit test error message

  24. 24

    Asp.net Identity Integration Test

  25. 25

    Error in test method in mvc for routing unit test

  26. 26

    DocumentDb Identity Provider for ASP.NET Core

  27. 27

    ASP.NET Core Identity Settings Not Working

  28. 28

    Asp MVC Core Identity Email Confirmation

  29. 29

    User.Identity.GetUserId() Owin Moq unit test

HotTag

Archive