/// <summary> /// Setup the test /// </summary> public ServiceAreaApiUnitTest() { DbContextOptions <DbAppContext> options = new DbContextOptions <DbAppContext>(); Mock <DbAppContext> dbAppContext = new Mock <DbAppContext>(null, options); ServiceAreaService _service = new ServiceAreaService(dbAppContext.Object); _ServiceAreaApi = new ServiceAreaController(_service); }
/// <summary> /// Setup the test /// </summary> public ServiceAreaApiUnitTest() { DbContextOptions <DbAppContext> options = new DbContextOptions <DbAppContext>(); Mock <DbAppContext> dbAppContext = new Mock <DbAppContext>(null, options); /* * * Here you will need to mock up the context. * * ItemType fakeItem = new ItemType(...); * * Mock<DbSet<ItemType>> mockList = MockDbSet.Create(fakeItem); * * dbAppContext.Setup(x => x.ModelEndpoint).Returns(mockItem.Object); * */ ServiceAreaService _service = new ServiceAreaService(dbAppContext.Object); _ServiceAreaApi = new ServiceAreaController(_service); }