/// <summary> /// Setup the test /// </summary> public CityApiUnitTest() { DbContextOptions <DbAppContext> options = new DbContextOptions <DbAppContext>(); Mock <DbAppContext> dbAppContext = new Mock <DbAppContext>(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); * */ CityApiService _service = new CityApiService(dbAppContext.Object); _CityApi = new CityApiController(_service); }
public CityApiControllerTesting() { _service = new Mock <ICityRepository>(); _controller = new CityApiController(_service.Object); }