jeudi 7 janvier 2021

Are there any ways to call database data to provide in Unit Testing

This is the Test that i have:

[Test]
public async Task Late_Test()
{
  var options = new DBContextOptionsBuilder<MyContext>()
  .Options;
  
  using(var context = MyContext(options))
  {
    //Act?
  }
    // Assert?
}

This is the service that I am trying to create a test for:

public async Task<int> LatesInMin(Model1 model1, bool isbool) 
{
 //code here
}

The code int the service also needs the data in the foreign keys attached to Model1. Can i call a data from the database and use it as the parameter when i call the service? Or do i have to manually provide that data as well? I tried and using linq causes an error and I searched that you cant use extension methods such as 'Where()' and 'FirstOrDefault()'

Aucun commentaire:

Enregistrer un commentaire