private static async Task CreateAppSettingsFile(IConfigurationRoot configuration) { object apsettingsContent = AppSettingsDefaultTemplate.Create(); var appsettingsFile = new FileInfo(Path.Combine(Environment.CurrentDirectory, _appsettingsFileName)); using var writer = new StreamWriter(appsettingsFile.OpenWrite()); await writer.WriteAsync(JsonConvert.SerializeObject(apsettingsContent)); writer.Close(); configuration.Reload(); }
public void Create_WithCurrentDirectory_CreatesDefaultAppSettingsObject() { // Arrange // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result); appSettings.Should().NotBeNull(); }
public void Create_WithCurrentDirectory_CreatesDefaultClassesDirectory() { // Arrange // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result); object magisterDirectoryObj = appSettings.GetType().GetProperty("ClassesDirectory").GetValue(appSettings); string magisterDirectory = (string)magisterDirectoryObj; magisterDirectory.Should().Contain("Classes"); }
public void Create_WithCurrentDirectory_CreatesDefaultSpreadsheetLocation() { // Arrange // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result); object spreadsheetDirectoryObj = appSettings.GetType().GetProperty("SpreadsheetDirectory").GetValue(appSettings); string spreadsheetDirectory = (string)spreadsheetDirectoryObj; spreadsheetDirectory.Should().Contain("Spreadsheets"); }
public void Create_WithCurrentDirectory_CreatesDefaultTestRepositoryLocation() { // Arrange // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result); object testRepositoryObj = appSettings.GetType().GetProperty("TestRepository").GetValue(appSettings); string testRepository = (string)testRepositoryObj; testRepository.Should().Contain("tests.json"); }
public void Create_WithCurrentDirectory_CreatesDefaultInstallationDate() { // Arrange DateTime expectedDateTime = DateTime.Now; DateTimeProvider.Now = () => expectedDateTime; // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result); object installationDateObj = appSettings.GetType().GetProperty("InstallationDate").GetValue(appSettings); DateTime installationDate = (DateTime)installationDateObj; installationDate.Should().Be(expectedDateTime); }
public void Create_WithCurrentDirectory_CreatesDefaultEppPlusLicense() { // Arrange // Act object result = AppSettingsDefaultTemplate.Create(); // Assert object epplusSettings = result.GetType().GetProperty("EPPlus").GetValue(result); object excelPackage = epplusSettings.GetType().GetProperty("ExcelPackage").GetValue(epplusSettings); excelPackage.Should().NotBeNull(); object licenseContextObj = excelPackage.GetType().GetProperty("LicenseContext").GetValue(excelPackage); licenseContextObj.Should().BeOfType <string>(); string licenseContext = (string)licenseContextObj; licenseContext.Should().Be("NonCommercial"); }