GivenQueuingReportAndPolling_WhenAllDataIsValid_TheReportIsDownloaded_AndIsReturnedInTheCallbackMethodAlongWithTheCallbackData() { // arrange var validFeedType = $"{_testEntriesIdentifier}_VALID_FEED_TYPE_"; var validFeedContent = "This is some test content. Und die Katze läuft auf der Straße."; var expectedFeedSubmissionId = "test feed submission Id"; var expectedFeedProcessingStatus = "_DONE_"; var feedSubmissionContainer = GenerateFeedContainer(validFeedContent, validFeedType); var expectedCallbackData = ("test", "callback", "data"); var expectedSubmissionReportContent = "Test submission report content. Und die Katze läuft auf der Straße."; Setup_SubmitFeed_Returns_FeedSubmissionIdWasGenerated(expectedFeedSubmissionId, validFeedType); Setup_GetFeedSubmissionList_Returns_FeedSubmittedSuccessfully(expectedFeedSubmissionId, expectedFeedProcessingStatus); Setup_GetFeedSubmissionResult_Returns_SubmissionReportContentStream(expectedFeedSubmissionId, expectedSubmissionReportContent); _actualFeedSubmissionReportContent = null; var feedUploadedEventNumberOfInvocations = 0; ReadOnlyDictionary <string, object> targetEventArgs = null; _easyMwsClient.FeedUploaded += (s, e) => { feedUploadedEventNumberOfInvocations++; targetEventArgs = e.TargetHandlerArgs; _actualFeedSubmissionReportContent = e.ProcessingReportContent; }; // act - queue report _easyMwsClient.QueueFeed(feedSubmissionContainer, "targetEventId", new Dictionary <string, object> { { "key1", "value1" }, { "key2", "value2" } }); // act - Poll report request process, in order for the queuedReport delegate to be invoked. _easyMwsClient.Poll(); // assert - callback was invoked successfully with expected content. Assert.AreEqual(2, targetEventArgs.Count); Assert.IsTrue(targetEventArgs.ContainsKey("key1")); Assert.IsTrue(targetEventArgs.ContainsKey("key2")); Assert.IsNotNull(targetEventArgs.FirstOrDefault(kvp => kvp.Value == "value1")); Assert.IsNotNull(targetEventArgs.FirstOrDefault(kvp => kvp.Value == "value2")); Assert.AreEqual(1, feedUploadedEventNumberOfInvocations); Assert.AreEqual(expectedSubmissionReportContent, _actualFeedSubmissionReportContent == null ? null : new StreamReader(_actualFeedSubmissionReportContent).ReadToEnd()); _mwsClientMock.Verify(mws => mws.SubmitFeed(It.IsAny <SubmitFeedRequest>()), Times.Once); _mwsClientMock.Verify(mws => mws.GetFeedSubmissionList(It.IsAny <GetFeedSubmissionListRequest>()), Times.Once); _mwsClientMock.Verify(mws => mws.GetFeedSubmissionResult(It.IsAny <GetFeedSubmissionResultRequest>()), Times.Once); var dbEntry = _dbContext.ReportRequestEntries.FirstOrDefault(rre => rre.ReportType == validFeedType); Assert.IsNull(dbEntry); }
private static GitRepositoryInfo CreateFromTFVC(ExternalLink gitExternalLink, IList <GitRepository> possibleRepos, ReadOnlyDictionary <int, string> changesetMapping, string sourceProjectName, string workItemSourceProjectName) { string commitID; string repoID; GitRepository gitRepo; //vstfs:///VersionControl/Changeset/{id} var changeSetIdPart = gitExternalLink.LinkedArtifactUri.Substring(gitExternalLink.LinkedArtifactUri.LastIndexOf('/') + 1); if (!int.TryParse(changeSetIdPart, out int changeSetId)) { return(null); } var commitIDKvPair = changesetMapping.FirstOrDefault(item => item.Key == changeSetId); if (string.IsNullOrEmpty(commitIDKvPair.Value)) { Trace.WriteLine($"Commit Id not found from Changeset Id {changeSetIdPart}."); return(null); } //assume the GitRepository source name is the work items project name, which changeset links needs to be fixed return(new GitRepositoryInfo(commitIDKvPair.Value, null, new GitRepository() { Name = workItemSourceProjectName })); }
public void CreateGame(NewGameOptionsVM options) { StatusText = "Creating Game..."; // TODO: Databind the GameSettings object in the NewGameOptionsVM var gameSettings = new NewGameSettings { GameName = "Test Game", MaxSystems = options.NumberOfSystems, SMPassword = options.GmPassword, DataSets = options.SelectedModList.Select(dvi => dvi.Directory), CreatePlayerFaction = options.CreatePlayerFaction, DefaultFactionName = options.FactionName, DefaultPlayerPassword = options.FactionPassword, DefaultSolStart = options.DefaultStart, }; Game = new Game(gameSettings); // TODO: Select default player more reliably CurrentPlayer = Game.Players[0]; CurrentAuthToken = new AuthenticationToken(CurrentPlayer, options.FactionPassword); ReadOnlyDictionary <Entity, AccessRole> roles = CurrentPlayer.GetAccessRoles(CurrentAuthToken); CurrentFaction = roles.FirstOrDefault(role => (role.Value & AccessRole.Owner) != 0).Key; StatusText = "Game Created."; StarSystemViewModel = new SystemView.StarSystemVM(this, Game, CurrentFaction); StarSystemViewModel.Initialise(); }
/// <summary> /// Using the output from "ffmpeg -version" work out the FFmpeg version. /// For pre-built binaries the first line should contain a string like "ffmpeg version x.y", which is easy /// to parse. If this is not available, then we try to match known library versions to FFmpeg versions. /// If that fails then we use one of the main libraries to determine if it's new/older than the latest /// we have stored. /// </summary> /// <param name="output"></param> /// <returns></returns> static private Version GetFFmpegVersion(string output) { // For pre-built binaries the FFmpeg version should be mentioned at the very start of the output var match = Regex.Match(output, @"ffmpeg version (\d+\.\d+)"); if (match.Success) { return(new Version(match.Groups[1].Value)); } else { // Try and use the individual library versions to determine a FFmpeg version // This lookup table is to be maintained with the following command line: // $ ./ffmpeg.exe -version | perl -ne ' print "$1=$2.$3," if /^(lib\w+)\s+(\d+)\.\s*(\d+)/' var lut = new ReadOnlyDictionary <Version, string> (new Dictionary <Version, string> { { new Version("4.1"), "libavutil=56.22,libavcodec=58.35,libavformat=58.20,libavdevice=58.5,libavfilter=7.40,libswscale=5.3,libswresample=3.3,libpostproc=55.3," }, { new Version("4.0"), "libavutil=56.14,libavcodec=58.18,libavformat=58.12,libavdevice=58.3,libavfilter=7.16,libswscale=5.1,libswresample=3.1,libpostproc=55.1," }, { new Version("3.4"), "libavutil=55.78,libavcodec=57.107,libavformat=57.83,libavdevice=57.10,libavfilter=6.107,libswscale=4.8,libswresample=2.9,libpostproc=54.7," }, { new Version("3.3"), "libavutil=55.58,libavcodec=57.89,libavformat=57.71,libavdevice=57.6,libavfilter=6.82,libswscale=4.6,libswresample=2.7,libpostproc=54.5," }, { new Version("3.2"), "libavutil=55.34,libavcodec=57.64,libavformat=57.56,libavdevice=57.1,libavfilter=6.65,libswscale=4.2,libswresample=2.3,libpostproc=54.1," }, { new Version("2.8"), "libavutil=54.31,libavcodec=56.60,libavformat=56.40,libavdevice=56.4,libavfilter=5.40,libswscale=3.1,libswresample=1.2,libpostproc=53.3," } }); // Create a reduced version string and lookup key from dictionary var reducedVersion = GetVersionString(output); // Try to lookup the string and return Key, otherwise if not found returns null return(lut.FirstOrDefault(x => x.Value == reducedVersion).Key); } }
private Card GetValidCard(Card externalCard) { if ((externalCard.ID == null && !string.IsNullOrEmpty(externalCard.Name)) || !CardDictionary.ContainsKey(externalCard.ID)) {//find card by name in current data, this allows for ID udpates or loading by name var updatedCard = CardDictionary.FirstOrDefault(c => c.Value.Name == externalCard.Name); return(updatedCard.Value); } else { return(CardDictionary[externalCard.ID]); } }
private void Register() { _LifeCycles = new ReadOnlyDictionary <string, ILifeCycle>( Reflector.CollectImplementedObject <ILifeCycle>() ); _Builtins = new ReadOnlyDictionary <string, IBuiltin>( Reflector.CollectImplementedObject <IBuiltin>() ); _Plugins = new ReadOnlyDictionary <string, IPlugin>( Reflector.CollectImplementedObject <IPlugin>() ); // KernelLifeCycle var kvp = _LifeCycles.FirstOrDefault(x => x.Value.IsDerived <IKLifeCycle>() ); _KernelLifeCycle = kvp.Value as IKLifeCycle; // ILifeCycle var kvps = _LifeCycles.Where(x => !x.Value.IsDerived <IKLifeCycle>() ); if (kvps.Any()) { _OtherLifeCycles = kvps .Select < KeyValuePair <string, ILifeCycle>, ILifeCycle >((x, i) => x.Value ); } if (null == _OtherLifeCycles) { _OtherLifeCycles = Enumerable.Empty <ILifeCycle>(); } }
public static string GetQFPayPaymentTypeCode(this string paymentType) { return(QFPayPaymentType.FirstOrDefault(a => a.Key.Equals(paymentType, StringComparison.OrdinalIgnoreCase)) .Value); }
public T?Resolve <T>(params IResolverParameter[] parameters) where T : class => _instances.FirstOrDefault(t => _typeComparer.Equals(t.Key, typeof(T))).Value as T;
private string GetExtension(string mimeType) { return(MimeTypes.FirstOrDefault(x => x.Key.Equals(mimeType)).Value); }