protected override TestAppConfig CreateTestConfig() { TestAppConfig config = base.CreateTestConfig(); config.shouldRegisterCommandNotifications = true; return(config); }
public void SaveAndLoad() { var configSave = new ConfigProvider(); var sectionA = new TestAppConfig(); var sectionB = new TestUiConfigSection(); configSave.SetSection(sectionA); configSave.SetSection(sectionB); configSave.SaveSettings(); var configLoad = new ConfigProvider(); configLoad.LoadSettings(); // TODO check if the sections are the same Assert.IsTrue(TestUtil.SerializeAndCompare( configSave.GetSection <TestAppConfig>(), configLoad.GetSection <TestAppConfig>() )); Assert.IsTrue(TestUtil.SerializeAndCompare( configSave.GetSection <TestUiConfigSection>(), configLoad.GetSection <TestUiConfigSection>() )); }
public void TestHostFileSectionUpdater_hostsInput_hostsOutput() { /* * The following assignments is made to trigger the constructor of PrimeDNS class. It won't work without that. */ var primeDns = new PrimeDns(); var config = new TestAppConfig(); var hostFileUpdater = new HostFile.HostFileUpdater(); var filePath = config.PrimeDnsTestsFiles + "test"; var inputFilePath = config.PrimeDnsTestsFiles + "hostsInput"; var outputFilePath = config.PrimeDnsTestsFiles + "hostsOutput"; const string data = "127.0.0.1\twww.dhamma.org\n127.0.0.1\twww.bing.com\n127.0.0.1\twww.goodreads.com"; if (File.Exists(filePath)) { File.Delete(filePath); } File.Copy(inputFilePath, filePath); hostFileUpdater.RemoveOldPrimeDnsSectionEntries(filePath); hostFileUpdater.FindPrimeDnsSectionBegin(filePath); Helper.FileHelper.InsertIntoFile(filePath, data, hostFileUpdater.PrimeDnsBeginLine + 1); Assert.IsTrue(Test_Helper.FileComparisonHelper.FilesAreEqual(filePath, outputFilePath)); }
public void FixtureSetUp() { Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true"); Directory.SetCurrentDirectory(PathUtil.IgniteHome); _changedConfig = TestAppConfig.Change(PathUtil.ExamplesAppConfigPath); }
public AuthorizationService(IAppInstallRepository installRepo, IOptions <TestAppConfig> testAppOptions, IOptions <SlackWebApiConfig> slackWebApiOptions) { _installRepo = installRepo; _testAppConfig = testAppOptions.Value; _slackWebApiConfig = slackWebApiOptions.Value; _httpClient = new HttpClient { BaseAddress = new Uri(_slackWebApiConfig.BaseAddress) }; }
public StatusController(IOptions <TestAppConfig> testAppOptions, IOptions <SlackWebApiConfig> slackWebApiOptions, IAppInstallRepository appInstallRepo, IDndService dndService, IUsersService usersService) { _testAppConfig = testAppOptions.Value; _slackWebApiConfig = slackWebApiOptions.Value; _appInstallRepo = appInstallRepo; _dndService = dndService; _usersService = usersService; }
public void OnSectionChangedEvent() { ConfigSectionChangedEventArgs testEventArgs = null; var config = new ConfigProvider(); config.OnSectionChanged += new EventHandler <ConfigSectionChangedEventArgs>((sender, args) => testEventArgs = args); var newSection = new TestAppConfig(); config.SetSection(newSection); Assert.IsNotNull(testEventArgs); }
public void FixtureSetUp() { Environment.SetEnvironmentVariable("IGNITE_NATIVE_TEST_CLASSPATH", "true"); Directory.SetCurrentDirectory(PathUtil.IgniteHome); // Copy file to a temp location and replace multicast IP finder with static. _configPath = Path.GetTempFileName(); var configText = File.ReadAllText(PathUtil.ExamplesAppConfigPath) .Replace("TcpDiscoveryMulticastIpFinder", "TcpDiscoveryStaticIpFinder"); File.WriteAllText(_configPath, configText); _changedConfig = TestAppConfig.Change(_configPath); }
public void FixtureSetUp() { _changedEnvVar = EnvVar.Set(Classpath.EnvIgniteNativeTestClasspath, bool.TrueString); Directory.SetCurrentDirectory(PathUtil.IgniteHome); // Copy file to a temp location and replace multicast IP finder with static. _configPath = Path.GetTempFileName(); var configText = File.ReadAllText(PathUtil.ExamplesAppConfigPath) .Replace("TcpDiscoveryMulticastIpFinder", "TcpDiscoveryStaticIpFinder"); File.WriteAllText(_configPath, configText); _changedConfig = TestAppConfig.Change(_configPath); }
public static void Gen1(string name, TestAppConfig appConfig, SuiteConfig suiteConfig, string typeName, SupportedType[] types, genFunc func, bool isLibrary) { string ending = isLibrary?"L":"E"; GenSample(name + "E1" + typeName + "F_" + ending, appConfig, suiteConfig, func(name + "E1" + typeName + "F_" + ending, types, null, true, false), isLibrary); GenSample(name + "E1" + typeName + "_P" + ending, appConfig, suiteConfig, func(name + "E1" + typeName + "_P" + ending, null, types, true, false), isLibrary); GenSample(name + "E1" + typeName + "FP" + ending, appConfig, suiteConfig, func(name + "E1" + typeName + "FP" + ending, types, types, true, false), isLibrary); GenSample(name + "E2" + typeName + "F_" + ending, appConfig, suiteConfig, func(name + "E2" + typeName + "F_" + ending, types, null, true, true), isLibrary); GenSample(name + "E2" + typeName + "_P" + ending, appConfig, suiteConfig, func(name + "E2" + typeName + "_P" + ending, null, types, true, true), isLibrary); GenSample(name + "E2" + typeName + "FP" + ending, appConfig, suiteConfig, func(name + "E2" + typeName + "FP" + ending, types, types, true, true), isLibrary); GenSample(name + "I1" + typeName + "F_" + ending, appConfig, suiteConfig, func(name + "I1" + typeName + "F_" + ending, types, null, false, false), isLibrary); GenSample(name + "I1" + typeName + "_P" + ending, appConfig, suiteConfig, func(name + "I1" + typeName + "_P" + ending, null, types, false, false), isLibrary); GenSample(name + "I1" + typeName + "FP" + ending, appConfig, suiteConfig, func(name + "I1" + typeName + "FP" + ending, types, types, false, false), isLibrary); GenSample(name + "I2" + typeName + "F_" + ending, appConfig, suiteConfig, func(name + "I2" + typeName + "F_" + ending, types, null, false, true), isLibrary); GenSample(name + "I2" + typeName + "_P" + ending, appConfig, suiteConfig, func(name + "I2" + typeName + "_P" + ending, null, types, false, true), isLibrary); GenSample(name + "I2" + typeName + "FP" + ending, appConfig, suiteConfig, func(name + "I2" + typeName + "FP" + ending, types, types, false, true), isLibrary); }
public static void GenTrees(string name, TestAppConfig appConfig, SuiteConfig suiteConfig, genFunc f1) { SupportedType[] tinyTypes = SupportedType.GetSupportedTypes(typeof(string)); SupportedType[] smallTypes = SupportedType.GetSupportedTypes(typeof(string), typeof(string)); SupportedType[] mediumTypes = SupportedType.GetSupportedTypes(typeof(string), typeof(string), typeof(int), typeof(int)); Gen1(name, appConfig, suiteConfig, "T", tinyTypes, f1, true); Gen1(name, appConfig, suiteConfig, "T", tinyTypes, f1, false); #if longbuild Gen1(name, appConfig, suiteConfig, "S", smallTypes, f1, true); Gen1(name, appConfig, suiteConfig, "S", smallTypes, f1, false); Gen1(name, appConfig, suiteConfig, "M", mediumTypes, f1, true); Gen1(name, appConfig, suiteConfig, "M", mediumTypes, f1, false); Gen1(name, appConfig, suiteConfig, "B", SupportedType.All, f1, true); Gen1(name, appConfig, suiteConfig, "B", SupportedType.All, f1, false); #endif }
public static void GenSamples(TestAppConfig appConfig, SuiteConfig suiteConfig) { string name = appConfig.provider.FileExtension; GenSample(name + "99L", appConfig, suiteConfig, GenAllIntrumentedTypeDefs(name + "99L"), true); GenSample(name + "99E", appConfig, suiteConfig, GenAllIntrumentedTypeDefs(name + "99E"), false); #if longbuild GenTrees(name + "10", appConfig, suiteConfig, new genFunc(GenerateLeaf)); GenTrees(name + "21", appConfig, suiteConfig, new genFunc(GenerateSmallTree)); GenTrees(name + "22", appConfig, suiteConfig, new genFunc(GenerateMedTree)); GenTrees(name + "23", appConfig, suiteConfig, new genFunc(GenerateLongTree)); #endif GenTrees(name + "29", appConfig, suiteConfig, new genFunc(GenerateTree)); // GenSample(name+"20", appConfig, suiteConfig, GenerateTree(name+"20", tinyTypes, null, true, false)); }
static void Main(string[] args) { Test(); return; TestAppConfig[] appConfigs = new TestAppConfig[] { new TestAppConfig(new CSharpCodeProvider(), new CodeGeneratorOptions()), new TestAppConfig(new VBCodeProvider(), new CodeGeneratorOptions()), new TestAppConfig(new JScriptCodeProvider(), new CodeGeneratorOptions()) }; SuiteConfig suiteConfig = new SuiteConfig(); suiteConfig.commands1.Add("@echo off"); string dir = Path.Combine(Environment.CurrentDirectory, "TestApps"); Directory.CreateDirectory(dir); Environment.CurrentDirectory = dir; foreach (TestAppConfig appConfig in appConfigs) { GenSamples(appConfig, suiteConfig); } Environment.CurrentDirectory = dir; using (StreamWriter writer = new StreamWriter("makeall.bat", false, Encoding.ASCII)) { foreach (string command in suiteConfig.commands1) { writer.WriteLine(command); } foreach (string command in suiteConfig.commands2) { writer.WriteLine(command); } foreach (string command in suiteConfig.commands3) { writer.WriteLine(command); } } }
public void TestRemoveLineFromFile_removeLineInput_removeLineOutput() { /* * The following assignments are made to trigger the constructor of the respective classes. It won't work without that. */ var primeDns = new PrimeDns(); var config = new TestAppConfig(); var hostFileUpdater = new HostFile.HostFileUpdater(); var filePath = config.PrimeDnsTestsFiles + "test"; var inputFilePath = config.PrimeDnsTestsFiles + "removeLineInput"; var outputFilePath = config.PrimeDnsTestsFiles + "removeLineOutput"; if (File.Exists(filePath)) { File.Delete(filePath); } File.Copy(inputFilePath, filePath); FileHelper.RemoveLineFromFile(filePath, "###---LINE-TO-REMOVE"); Assert.IsTrue(FileComparisonHelper.FilesAreEqual(filePath, outputFilePath)); }
public TestAppContext(DbContextOptions <TestAppContext> dbContextOptions, IOptions <TestAppConfig> configOptions) : base(dbContextOptions) { _config = configOptions.Value; }
public InstallController(IOptions <TestAppConfig> testAppOptions, IOptions <SlackWebApiConfig> slackWebApiOptions) { _testAppConfig = testAppOptions.Value; _slackWebApiConfig = slackWebApiOptions.Value; }
static void GenSample(string name, TestAppConfig appConfig, SuiteConfig suiteConfig, CodeTypeDeclarationCollection instrumentedTypes, bool isLibrary) { CodeDomProvider provider = appConfig.provider; CodeGeneratorOptions options = appConfig.options; CodeStatementCollection testStatements = GenTestCases(instrumentedTypes); CodeTypeDeclaration mainClass = AssemblyGenerator.GenMainClass(testStatements); mainClass.Name = name + "App"; CodeNamespace codeNamespace = AssemblyGenerator.GenNamespaceForInstrumentation(name + "App", provider is VBCodeProvider); codeNamespace.Types.Add(SupportedType.jscriptHackType); codeNamespace.Types.AddRange(instrumentedTypes); codeNamespace.Types.Add(mainClass); CodeCompileUnit unit = AssemblyGenerator.GenInstrumentedAssembly("root\\TestAppZ"); unit.Namespaces.Add(codeNamespace); // CodeCompileUnit unitMod = AssemblyGenerator.GenInstrumentedModule(); string fileName = name + "." + provider.FileExtension; string assemblyName = name + "." + (isLibrary?"dll":"exe"); string target = (isLibrary?" /target:library":""); #if SUBDIRSFORLANG string subDir = Path.Combine(Environment.CurrentDirectory, provider.FileExtension); Directory.CreateDirectory(subDir); string oldDir = Environment.CurrentDirectory; Environment.CurrentDirectory = subDir; #endif Console.WriteLine("Generating " + fileName); using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.ASCII)) { provider.CreateGenerator().GenerateCodeFromCompileUnit(unit, writer, options); } #if xxx string fileNameMod = name + "Mod." + provider.FileExtension; string moduleName = name + "Mod." + "mod"; using (StreamWriter writer = new StreamWriter(fileNameMod, false, Encoding.ASCII)) { provider.CreateGenerator().GenerateCodeFromCompileUnit(unitMod, writer, options); } #endif #if SUBDIRSFORLANG Environment.CurrentDirectory = oldDir; #endif #if SUBDIRSFORLANG suiteConfig.commands1.Add("cd " + provider.FileExtension); #endif suiteConfig.commands1.Add("echo Building " + fileName); suiteConfig.commands1.Add(appConfig.GetComplerCommand(unit) + target + " /out:" + assemblyName + " " + fileName); // suiteConfig.commands1.Add(appConfig.GetComplerCommand(unit) + " /target:module /out:" + moduleName + " " + fileNameMod); #if SUBDIRSFORLANG suiteConfig.commands1.Add("cd .."); #endif #if SUBDIRSFORLANG suiteConfig.commands2.Add("cd " + provider.FileExtension); #endif suiteConfig.commands2.Add("echo InstallUtil " + assemblyName); suiteConfig.commands2.Add("InstallUtil /LogToConsole=false " + assemblyName); #if SUBDIRSFORLANG suiteConfig.commands2.Add("cd .."); #endif }