public void Should_Success_Generate_Memory_Cache() { var services = new ServiceCollection(); services.AddMemoryCache(); var serviceProvider = services.BuildServiceProvider(); var memoryCache = serviceProvider.GetService <IMemoryCache>(); var mockServiceProvider = new Mock <IServiceProvider>(); mockServiceProvider.Setup(sp => sp.GetService(typeof(IMemoryCacheManager))).Returns(new MemoryCacheManager(memoryCache)); mockServiceProvider.Setup(sp => sp.GetService(typeof(ICoreHttpClientService))).Returns(new CoreHttpClientServiceTest()); var coreData = new CoreData(mockServiceProvider.Object); try { coreData.SetBankAccount(); coreData.SetCategoryCOA(); coreData.SetDivisionCOA(); coreData.SetPPhCOA(); coreData.SetUnitCOA(); Assert.True(true); //coreData. } catch (Exception e) { throw e; } }