Skip to content

Instantly share code, notes, and snippets.

View bjornmicallef's full-sized avatar

Bjorn Micallef bjornmicallef

View GitHub Profile
...
"tsConfig": "projects/mfe1/tsconfig.app.json",
"assets": [
"projects/mfe1/src/favicon.ico",
"projects/mfe1/src/assets",
{
"glob": "**/*",
"input": "projects/common/assets/",
"output": "./assets/"
}
<img alt="Logo" width="100px" height="85px" src="../assets/images/logo.png" />
<h1>Angular MFE Host</h1>
<a routerLink='/'>Main</a> &#160;
<a routerLink='/mfe1'>Link to MFE</a>
<router-outlet></router-outlet>
...
"tsConfig": "projects/host/tsconfig.app.json",
"assets": [
"projects/host/src/favicon.ico",
"projects/host/src/assets",
{
"glob": "**/*",
"input": "projects/common/assets/",
"output": "./assets/"
}
[TestClass]
public class CacheServiceTests
{
private CacheService _cacheService;
private Mock<IConnectionMultiplexer> _mockMuxer;
private Mock<IDatabase> _mockRedisDb;
public CacheServiceTests()
{
_mockMuxer = new Mock<IConnectionMultiplexer>();
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddMemoryCache();
services.AddSingleton<IConnectionMultiplexer>(provider => ConnectionMultiplexer.Connect("your redis connection string"));
services.AddScoped<ICacheService, CacheService>();
services.AddScoped<IWeatherService, WeatherService>();
}
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly ILogger<WeatherForecastController> _logger;
private readonly ICacheService _cacheService;
private readonly IWeatherService _weatherService;
public WeatherForecastController(ILogger<WeatherForecastController> logger, ICacheService cacheService, IWeatherService weatherService)
{
public class WeatherService : IWeatherService
{
public WeatherService()
{
}
public async Task<OpenWeather> GetWeather(string cityName)
{
if (string.IsNullOrWhiteSpace(cityName))
throw new ArgumentNullException("Provide city name");
public class CacheService : ICacheService
{
private readonly IConnectionMultiplexer _muxer;
private readonly IDatabase _conn;
private readonly IMemoryCache _memCache;
public CacheService(IConnectionMultiplexer muxer, IMemoryCache memCache)
{
_muxer = muxer;
_conn = _muxer.GetDatabase();
public class ApplicationTests
{
private const string testAppSettingsFileDirectory = @"C:\test\EscapeMines\EscapeMines.IntegrationTests\TestAppSettings";
private const string binAppSettingsFileDirectoryAndName = @"C:\test\EscapeMines\EscapeMines\bin\Debug\netcoreapp3.1\appsettings.json";
protected Process StartApplication(string testAppSettingsFileName)
{
// implementation
}
public class ApplicationTests
{
private const string testAppSettingsFileDirectory = @"C:\<path>\<SolutionName>\<IntegrationTestsProject>\TestAppSettings";
private const string binAppSettingsFileDirectoryAndName = @"C:\<path>\<SolutionName>\<ConsoleAppProject>\bin\Debug\netcoreapp3.1\appsettings.json";
protected Process StartApplication(string testAppSettingsFileName)
{
File.Copy($"{testAppSettingsFileDirectory}\\{testAppSettingsFileName}", binAppSettingsFileDirectoryAndName, true);
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = @"C:\<path>\<SolutionName>\<ConsoleAppProject>\bin\Debug\netcoreapp3.1\EscapeMines.exe";