public DataTransfer <GetOutput> Get(string id) { DataTransfer <GetOutput> tranfer = new DataTransfer <GetOutput>(); System.Int32 systemprocessid = 0; if (!string.IsNullOrEmpty(id) && System.Int32.TryParse(id, out systemprocessid)) { SystemProcess systemprocess = _iSystemProcessRepository.GetSystemProcess(systemprocessid); if (systemprocess != null) { tranfer.IsSuccess = true; GetOutput output = new GetOutput(); output.CopyFrom(systemprocess); tranfer.Data = output; } else { tranfer.IsSuccess = false; tranfer.Errors = new string[1]; tranfer.Errors[0] = "Error: No record found."; } } else { tranfer.IsSuccess = false; tranfer.Errors = new string[1]; tranfer.Errors[0] = "Error: Invalid request."; } return(tranfer); }
public DataTransfer <GetOutput> Get(string _id) { DataTransfer <GetOutput> tranfer = new DataTransfer <GetOutput>(); System.Int32 performancestatisticid = 0; if (!string.IsNullOrEmpty(_id) && System.Int32.TryParse(_id, out performancestatisticid)) { PerformanceStatistic performancestatistic = _iPerformanceStatisticRepository.GetPerformanceStatistic(performancestatisticid); if (performancestatistic != null) { tranfer.IsSuccess = true; GetOutput output = new GetOutput(); output.CopyFrom(performancestatistic); tranfer.Data = output; } else { tranfer.IsSuccess = false; tranfer.Errors = new string[1]; tranfer.Errors[0] = "Error: No record found."; } } else { tranfer.IsSuccess = false; tranfer.Errors = new string[1]; tranfer.Errors[0] = "Error: Invalid request."; } return(tranfer); }
static void Main(string[] args) { var parsedArgs = Args.Parse(args); if (parsedArgs == null) { DisplayHelp(); return; } var nserviceBusModel = NServiceBusReadmeModel.LoadFrom(parsedArgs.AssemblyPath); var readmeWriter = new NServiceBusReadmeWriter() .Write(nserviceBusModel); GetOutput(parsedArgs)(readmeWriter.ToString()); }
public void WhenICallGetANotImplementedExceptionIsThrown() { // Arrange IGetOutput subject = new GetOutput(); // Act // Assert Assert.Throws <NotImplementedException>(() => subject.Get(1)); }
private static async Task <IReadOnlyList <TOutput> > GetCommitsAsync <TRecord, TOutput>( GetRangeAsync <TRecord> getCommitRangeAsync, GetTimestamp <TRecord> getCommitTimestamp, GetOutput <TRecord, TOutput> getOutput, long start, long end, int batchSize, int minimumRecords) { var commits = new List <TOutput>(); var totalFetched = 0; int fetched; do { var items = await getCommitRangeAsync( start, end, batchSize); fetched = items.Count; totalFetched += items.Count; var commitTimestampGroups = items .GroupBy(x => getCommitTimestamp(x)) .ToDictionary(x => x.Key, x => (IReadOnlyList <TRecord>)x.ToList()); var commitTimestamps = commitTimestampGroups .Keys .OrderBy(x => x) .ToList(); if (commitTimestamps.Count == 1 && fetched == batchSize) { // We've gotten a whole page but can't confidently move the start commit timestamp forward. throw new InvalidOperationException( "Only one commit timestamp was encountered. A larger page size is required to proceed."); } else if (fetched < batchSize) { // We've reached the end and we have all of the last commit. start = end; commits.AddRange(GetOutputList(getOutput, commitTimestamps, commitTimestampGroups)); } else if (fetched > 0) { // Ignore the last commit timestamp since we might have a partial commit. commitTimestamps.RemoveAt(commitTimestamps.Count - 1); start = commitTimestamps.Last(); commits.AddRange(GetOutputList(getOutput, commitTimestamps, commitTimestampGroups)); } }while (fetched > 0 && start < end && totalFetched < minimumRecords); return(commits); }
public void NumbersFrom1To100ThatAreFizzBuzz() { // Arrange IGetOutput subject = new GetOutput(); var listOfFizzBuzz = new List <int>() { 15, 30, 45, 60, 75, 90 }; // Act // Assert Assert.All(listOfFizzBuzz, x => Assert.Equal("FizzBuzz", subject.Get(x))); }
public void NumbersFrom1To100ThatAreBuzzOnly() { // Arrange IGetOutput subject = new GetOutput(); var listOfBuzzOnly = new List <int>() { 5, 10, 20, 25, 35, 40, 50, 55, 65, 70, 80, 85, 100 }; // Act // Assert Assert.All(listOfBuzzOnly, x => Assert.Equal("Buzz", subject.Get(x))); }
public void NumbersFrom1To100ThatAreFizzOnly() { // Arrange IGetOutput subject = new GetOutput(); var listOfFizzOnly = new List <int>() { 3, 6, 9, 12, 18, 21, 24, 27, 33, 36, 39, 42, 48, 51, 54, 57, 63, 66, 69, 72, 78, 81, 84, 87, 93, 96, 99 }; // Act // Assert Assert.All(listOfFizzOnly, x => Assert.Equal("Fizz", subject.Get(x))); }
private static IReadOnlyList <TOutput> GetOutputList <TRecord, TOutput>( GetOutput <TRecord, TOutput> getOutput, IReadOnlyList <long> orderedTimestamps, IReadOnlyDictionary <long, IReadOnlyList <TRecord> > timestampToRecords) { var outputList = new List <TOutput>(); foreach (var timestamp in orderedTimestamps) { outputList.Add(getOutput(timestamp, timestampToRecords[timestamp])); } return(outputList); }
public void NumbersFrom1To100ThatAreNotFizzOrBuzzOrFizzBuzz() { // Arrange IGetOutput subject = new GetOutput(); var listOfNumbers = new List <int>() { 1, 2, 4, 7, 8, 11, 13, 14, 16, 17, 19, 22, 23, 26, 28, 29, 31, 32, 34, 37, 38, 41, 43, 44, 46, 47, 49, 52, 53, 56, 58, 59, 61, 62, 64, 67, 68, 71, 73, 74, 76, 77, 79, 82, 83, 86, 88, 89, 91, 92, 94, 97, 98 }; // Act // Assert Assert.All(listOfNumbers, x => Assert.Equal(x.ToString(), subject.Get(x))); }
public static async Task <IReadOnlyList <TOutput> > GetCommitsAsync <TRecord, TOutput>( GetRangeAsync <TRecord> getCommitRangeAsync, GetTimestamp <TRecord> getCommitTimestamp, GetOutput <TRecord, TOutput> getOutput, DateTimeOffset start, DateTimeOffset end, int batchSize) { return(await GetCommitsAsync( getCommitRangeAsync, getCommitTimestamp, getOutput, start.UtcTicks, end.UtcTicks, batchSize, minimumRecords : 1)); }