public void TestInvalidRomanToArabicConversion() { var number = "WMCMLXXIII"; long actual; var result = ArabicRomanConverter.TryToArabic(number, out actual); Assert.IsFalse(result); }
public void TestSuccessfulArabicToRomanConversion() { var number = 1973; var expected = "MCMLXXIII"; var actual = ArabicRomanConverter.ToRoman(number); Assert.AreEqual(expected, actual); }
public async Task <HttpResponseMessage> Count() { // For each partition client, keep track of partition information and the number of words ConcurrentDictionary <Int64RangePartitionInformation, long> totals = new ConcurrentDictionary <Int64RangePartitionInformation, long>(); IList <Task> tasks = new List <Task>(); foreach (Int64RangePartitionInformation partition in await this.GetServicePartitionKeysAsync()) { try { ServicePartitionClient <HttpCommunicationClient> partitionClient = new ServicePartitionClient <HttpCommunicationClient>(communicationFactory, serviceUri, new ServicePartitionKey(partition.LowKey)); await partitionClient.InvokeWithRetryAsync( async (client) => { HttpResponseMessage response = await client.HttpClient.GetAsync(new Uri(client.Url, "Count")); string content = await response.Content.ReadAsStringAsync(); totals[partition] = Int64.Parse(content.Trim()); }); } catch (Exception ex) { // Sample code: print exception ServiceEventSource.Current.OperationFailed(ex.Message, "Count - run web request"); } } var total = totals.Aggregate <KeyValuePair <Int64RangePartitionInformation, long>, long>(0, (sum, next) => next.Value + sum); StringBuilder sb = new StringBuilder(); sb.Append("<h1> Total:"); sb.AppendFormat("{0} ({1})", total, ArabicRomanConverter.ToRoman(total)); sb.Append("</h1>"); sb.Append("<table><tr><td>Partition ID</td><td>Key Range</td><td>Total</td></tr>"); foreach (KeyValuePair <Int64RangePartitionInformation, long> partitionData in totals.OrderBy(partitionData => partitionData.Key.LowKey)) { sb.Append("<tr><td>"); sb.Append(partitionData.Key.Id); sb.Append("</td><td>"); sb.AppendFormat("{0} - {1}", partitionData.Key.LowKey, partitionData.Key.HighKey); sb.Append("</td><td>"); sb.Append(partitionData.Value); sb.Append("</td></tr>"); } sb.Append("</table>"); return(new HttpResponseMessage() { Content = new StringContent(sb.ToString(), Encoding.UTF8, "text/html") }); }
public void TestSuccessfulRomanToArabicConversion() { var number = "MCMLXXIII"; var expected = 1973; long actual; var result = ArabicRomanConverter.TryToArabic(number, out actual); Assert.IsTrue(result); Assert.AreEqual(expected, actual); }