public void Test_With_Proper_Input_Text_File() { //Arrange var inputTextLines = EmbeddedResourceUtility.GetResourceDataLineTexts(Assembly.GetExecutingAssembly(), "UnitTesting.InputText.txt").ToList(); var romanNumeralSymbolValues = new RomanNumeralSymbolValues(); var romanNumeralRuleCheckers = new List <IRomanNumeralRuleChecker> { new MaxSuccessiveRepetitionRuleChecker(), new FourTimesRepetitionWithLowerValueCharacterAtFourthPositionRuleChecker(), new NotAllowedRepetitionRuleChecker(), new AllowedSubtractionsRuleChecker(), new NotAllowedSubtractionRuleChecker(romanNumeralSymbolValues), new OnlyOneSmallValueFromlLargeValueSubtractionAllowedRuleChecker(romanNumeralSymbolValues), }; var standardRomanNumeralCalculator = new StandardRomanNumeralCalculator(romanNumeralSymbolValues, romanNumeralRuleCheckers); var intergalacticProcessor = new IntergalacticProcessor(standardRomanNumeralCalculator, romanNumeralSymbolValues); //Action var outputTextLines = intergalacticProcessor.Process(inputTextLines); //Assert Assert.AreEqual(outputTextLines[0], "pish tegj glob glob is 42"); Assert.AreEqual(outputTextLines[1], "glob prok Silver is 68 Credits"); Assert.AreEqual(outputTextLines[2], "glob prok Gold is 57800 Credits"); Assert.AreEqual(outputTextLines[3], "glob prok Iron is 782 Credits"); Assert.AreEqual(outputTextLines[4], "I have no idea what you are talking about"); }
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req, ILogger log) { var embeddedResourceUtility = new EmbeddedResourceUtility(); var html = embeddedResourceUtility.GetContent("Content.RegulationForm.html"); var response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StringContent(html); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); return(response); }
/// <summary> /// Return the contents of one of the WebDAV XML resources /// </summary> /// <param name="resourceAddress">Name of the resource</param> /// <param name="formatArgs">A set of parameters to substitute into the resource</param> /// <returns>The resource with substitutions made</returns> public static string GetText(string resourceAddress, params object[] formatArgs) { string text; text = EmbeddedResourceUtility.GetTextDocument(resourceAddress); // TODO: BUG: each formatArg value needs to be xml-encoded if (formatArgs.Length > 0) { text = string.Format(text, formatArgs); } return(text); }
private void CreateConfiguration() { var nodeAddress = this.parameters.Address; var leaseAgentAddress = FabricNode.GetNextAddress(nodeAddress); var runtimeServiceAddress = FabricNode.GetNextAddress(leaseAgentAddress); var clientConnectionAddress = FabricNode.GetNextAddress(runtimeServiceAddress); var gatewayIpcAddress = FabricNode.GetNextAddress(clientConnectionAddress); this.ClientConnectionAddress = clientConnectionAddress; string voters = FabricNode.GetVoters(this.parameters.Voters); var fabricConfigData = new NameValueCollection { { "WORKING_DIR", this.FabricWorkingDirectory }, { "NODE_ID", this.parameters.NodeId }, { "NODE_NAME", this.parameters.NodeName }, { "NODE_ADDRESS", nodeAddress.ToString() }, { "LEASE_AGENT_ADDRESS", leaseAgentAddress.ToString() }, { "RUNTIME_SERVICE_ADDRESS", runtimeServiceAddress.ToString() }, { "CLIENT_CONNECTION_ADDRESS", clientConnectionAddress.ToString() }, { "GATEWAY_IPC_ADDRESS", gatewayIpcAddress.ToString() }, { "IMAGE_STORE_CONNECTION_STRING", this.parameters.ImageStoreConnectionString }, { "FEDERATION_DIR", Path.Combine(this.FabricWorkingDirectory, "federation") }, { "VOTERS", voters }, { "NAMING_SERVICE_DIR", Path.Combine(this.FabricWorkingDirectory, "communication") }, { "FM_STORE_DIR", this.parameters.ReliabilityPath }, { "RA_STORE_DIR", this.parameters.ReliabilityPath }, { "ACTIVATION_CONFIG_DIR", this.BinariesPath }, { "START_PORT", (this.parameters.StartPort + FabricNode.PortsReservedForFabric).ToString() }, { "END_PORT", this.parameters.EndPort.ToString() }, { "FAULT_DOMAIN", this.parameters.FaultDomainId.ToString() }, { "UPGRADE_DOMAIN", this.parameters.UpgradeDomainId.ToString() }, }; string configText = EmbeddedResourceUtility.ReadTemplateAndApplyVariables("FabricConfig.cfg.template", fabricConfigData); File.WriteAllText(this.ConfigPath, configText); var hostConfigData = new NameValueCollection { { "NODE_ID", this.parameters.NodeId }, { "CLIENT_CONNECTION_ADDRESS", clientConnectionAddress.ToString() }, { "LEASE_AGENT_ADDRESS", leaseAgentAddress.ToString() }, { "NODE_ADDRESS", nodeAddress.ToString() }, { "RUNTIME_SERVICE_ADDRESS", runtimeServiceAddress.ToString() } }; string hostConfigText = EmbeddedResourceUtility.ReadTemplateAndApplyVariables("HostConfig.ini.template", hostConfigData); File.WriteAllText(Path.Combine(this.BinariesPath, "hostconfig.ini"), hostConfigText); var clusterConfigData = new NameValueCollection { { "ACTIVATION_CONFIG_DIR", this.BinariesPath }, { "IMAGE_STORE_CONNECTION_STRING", this.parameters.ImageStoreConnectionString }, { "VOTERS", voters }, { "WORKING_DIR", this.FabricWorkingDirectory }, }; string clusterConfigText = EmbeddedResourceUtility.ReadTemplateAndApplyVariables("ClusterConfig.ini.template", clusterConfigData); File.WriteAllText(Path.Combine(this.BinariesPath, "ClusterConfig.ini"), clusterConfigText); var activationConfigData = new NameValueCollection { }; var activationConfigText = EmbeddedResourceUtility.ReadTemplateAndApplyVariables("cfg.template", activationConfigData); File.WriteAllText(Path.Combine(this.BinariesPath, ".cfg"), activationConfigText); }