コード例 #1
0
ファイル: Installation.cs プロジェクト: wouterfennis/Cifra
        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();
        }
コード例 #2
0
        public void Create_WithCurrentDirectory_CreatesDefaultAppSettingsObject()
        {
            // Arrange

            // Act
            object result = AppSettingsDefaultTemplate.Create();

            // Assert
            object appSettings = result.GetType().GetProperty("AppSettings").GetValue(result);

            appSettings.Should().NotBeNull();
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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");
        }