0
   public class StudentService
    {   


}

I have a student class where I am accessing MsDbContext to do entity framework related work.In the above code, options are coming from abstractDbBasedService.

AbstractDbBasedService :

public class AbstractDbBasedService

}

Now, I have a test class where I am accessing all the above services.

StudentTestClass :

    public class StudentServicesTests : AbstractDbBasedService
    {

}        
       [Fact]
        public void Assert_CreatedStudent_WhenStudentParemeterInvalid()
        {

        }

}

when I am trying to the run the tests, It is giving me the error - The following constructor parameter did not have matching fixture data:DbContextOptions'1 options. Please help me on this.

LOKI321
  • 325
  • 1
  • 4
  • 13
  • 1
    Why aren't you using the search function? I answered the exact same question just a day ago here: http://stackoverflow.com/questions/41349140/xunit-di-through-overridden-startup-file-net-core/41350245#41350245. In short: You can't inject services into Test classes, only fixtures and only then when you implement `IClassFixture` or `ICollectionFixture` in your test class – Tseng Dec 28 '16 at 21:30
  • I am using asp.net core1.1 and Autofixtures(from nuget package manager) is not supported for Asp.net core1.1 – LOKI321 Dec 29 '16 at 04:47
  • AutoFixture is ASP.NET Core agnostic, it's only dependency is the Unit Test framework, you just need to target `net452` in your test library instead of `netcoreapp1.1` – Tseng Dec 29 '16 at 08:20

0 Answers0