/************************************************** * Event Handlers **************************************************/ protected override void Awake() { base.Awake(); //must be included in every child of MenuController (due to Unity bug) ToggleKey = KeyCode.T; ToggleEnabled = true; _teamsController = global::TeamsController.Instance; }
//IEnumerator WaitAndPrint(float waitTime) IEnumerator InitTeamsNumber() { GameObject obj; do { obj = GameObject.FindGameObjectWithTag("TeamsController"); if (obj != null) { teamsController = obj.GetComponent<TeamsController>(); if (teamsController) { teamNumber = teamsController.numberOfTeams; } else { Debug.LogError("Cannot GetComponent<TeamsController> "); } } else { yield return new WaitForSeconds(0.1f); // contimue after 100ms } } while (obj == null); }
/* private int playerCount = 0; void OnPlayerConnected(NetworkPlayer player) { Debug.Log("Player " + playerCount++ + " connected from " + player.ipAddress + ":" + player.port); } void OnPlayerDisconnected(NetworkPlayer player) { Debug.Log("Clean up after player " + player); //Network.RemoveRPCs(player); //Network.DestroyPlayerObjects(player); } */ /* public override void OnClientSceneChanged(NetworkConnection conn) { Debug.Log("OnClientSceneChanged"); base.OnClientSceneChanged(conn); InitTeamController(); } public override void OnClientConnect(NetworkConnection conn) { Debug.Log("oNcLIENTcoNNECT"); base.OnClientConnect(conn); //InitTeamController(); } public override void OnStartServer() { Debug.Log("oNsTARTsERVER"); base.OnStartServer(); //SpawnTeamController(); } */ void SpawnTeamController() { Debug.Log("SpawnTeamController"); GameObject obj = Instantiate(teamCtrlPrefub); teamCtrl = obj.GetComponent<TeamsController>(); NetworkServer.Spawn(obj); }
/************************************************** * Event Handlers **************************************************/ protected override void Awake() { base.Awake(); ToggleKey = KeyCode.K; ToggleEnabled = true; _teamsController = TeamsController.Instance; }
/************************************************** * Event Handlers **************************************************/ // Use this for initialization protected override void Awake() { _matchController = global::MatchController.Instance; _teamsController = global::TeamsController.Instance; base.Awake(); ToggleKey = KeyCode.Tab; ToggleEnabled = true; }
private void Start() { _teamsController = global::TeamsController.Instance; _cameraController = global::CameraController.Instance; _hudController = global::HUDController.Instance; _hudController.UpdateHealthHUD(Health); _userController = global::UserController.Instance; _userController.SetDead(false); }
/************************************************************ * Event Handlers ************************************************************/ // Use this for initialization private void Awake() { _teamsController = global::TeamsController.Instance; _animator = GetComponent<Animator>(); _spriteRenderers = GetComponentsInChildren<SpriteRenderer>(); if (networkView.isMine) { _userController = global::UserController.Instance; _userController.SetPlayer(GetComponent<Player>()); } }
protected override void Awake() { base.Awake(); _teamsController = global::TeamsController.Instance; _userController = global::UserController.Instance; _hudController = global::HUDController.Instance; _weaponModels = new List<WeaponModel>(global::WeaponContainer.Instance.WeaponModels); _currentWeapon = _weaponModels.First(w => w.Type == WeaponType.Pistol); ToggleKey = KeyCode.B; ToggleEnabled = true; }
private void BindTeams() { List<TeamsController.TeamViewObject> data = null; using (TeamsController tc = new TeamsController()) { data = tc.GetScopedTeamViewObject(CurrentUser.UserID, Permissions.TeamManagement.ViewTeams).ToList(); } GridViewData<TeamsController.TeamViewObject> gvd = new GridViewData<TeamsController.TeamViewObject>(typeof(TeamsController.TeamViewObject)); gvd.AddData(data); gvAllTeams.GridViewItems = gvd; gvAllTeams.DataSource = data; gvAllTeams.DataBind(); // bind widgets rptWidgets.DataSource = data.Where(i => DateTime.Today <= i.End) .OrderBy(i => i.ProgramName).ThenByDescending(i => i.AgeCutoff) .Select(i => i.TeamID); rptWidgets.DataBind(); }
public async Task Details_WhenIdIsNotNullAndTeamNotFound_ShouldReturnNotFound() { // Arrange var teamsIndexViewModel = A.Fake <ITeamsIndexViewModel>(); var teamsDetailsViewModel = A.Fake <ITeamsDetailsViewModel>(); var teamRepository = A.Fake <ITeamRepository>(); Team?team = null; A.CallTo(() => teamRepository.GetTeamAsync(A <int> .Ignored)).Returns(team); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new TeamsController(teamsIndexViewModel, teamsDetailsViewModel, teamRepository, sharedRepository); int?id = 0; // Act var result = await testController.Details(id); // Assert A.CallTo(() => teamRepository.GetTeamAsync(id.Value)).MustHaveHappenedOnceExactly(); result.ShouldBeOfType <NotFoundResult>(); }
public async Task Index_ShouldReturnTeamsIndexView() { // Arrange var teamsIndexViewModel = A.Fake <ITeamsIndexViewModel>(); var teamsDetailsViewModel = A.Fake <ITeamsDetailsViewModel>(); var teamRepository = A.Fake <ITeamRepository>(); var teams = new List <Team>(); A.CallTo(() => teamRepository.GetTeamsAsync()).Returns(teams); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new TeamsController(teamsIndexViewModel, teamsDetailsViewModel, teamRepository, sharedRepository); // Act var result = await testController.Index(); // Assert A.CallTo(() => teamRepository.GetTeamsAsync()).MustHaveHappenedOnceExactly(); teamsIndexViewModel.Teams.ShouldBe(teams); result.ShouldBeOfType <ViewResult>(); ((ViewResult)result).Model.ShouldBe(teamsIndexViewModel); }
public void PutTeam() { int teamId = 1; String name = "test"; Team testObject = new Team(); testObject.teamId = teamId; testObject.name = name; Mock <ITeamRepository> myMock = new Mock <ITeamRepository>(); myMock.Setup(x => x.Update(teamId, testObject)) .Returns(Task.FromResult(teamId)); TeamsController teamsController = new TeamsController(myMock.Object); Task <IHttpActionResult> returnedTask = teamsController.PutTeam(1, testObject); Assert.IsInstanceOfType(returnedTask.Result, typeof(StatusCodeResult)); Assert.AreEqual(((StatusCodeResult)returnedTask.Result).StatusCode, HttpStatusCode.NoContent); myMock.VerifyAll(); }
public async Task Delete_TeamIdDoesNotExists_ReturnsNotFoundView() { var team1 = new Team() { Name = "team1" }; var team2 = new Team() { Name = "team2" }; var service = new Mock <ITeamRepository>(); service.Setup(x => x.GetTeam(1)).ReturnsAsync(team1); service.Setup(x => x.GetTeam(2)).ReturnsAsync(team2); var controller = new TeamsController(service.Object); var result = await controller.Delete(1555); var viewResult = (ViewResult)result; Assert.AreEqual("NotFound", viewResult.ViewName); }
public async Task Delete_TeamIdExists_ReturnsSameTeam() { var team1 = new Team() { Name = "team1" }; var team2 = new Team() { Name = "team2" }; var service = new Mock <ITeamRepository>(); service.Setup(x => x.GetTeam(1)).ReturnsAsync(team1); service.Setup(x => x.GetTeam(2)).ReturnsAsync(team2); var controller = new TeamsController(service.Object); var result = await controller.Delete(1); var model = ((ViewResult)result).Model as Team; Assert.AreEqual(team1, model); }
public async Task Edit_TeamWithIdExistsAndIsInvalid_ReturnsSameModel() { var invalidTeam = new Team() { TeamId = 0, Name = "Wi", DateOfFounding = new DateTime(1999, 10, 10) }; var teams = new List <Team>() { invalidTeam }; var service = new Mock <ITeamRepository>(); service.Setup(x => x.GetTeam(0)).ReturnsAsync(invalidTeam); var controller = new TeamsController(service.Object); controller.ModelState.AddModelError("NiePodobaMiSie", "BoTak"); var result = await controller.Edit(0, invalidTeam); var model = ((ViewResult)result).Model as Team; Assert.AreEqual(invalidTeam, model); }
public void UpdateTeamModifiesTeamToList() { TeamsController controller = new TeamsController(new TestMemoryTeamRepository()); var teams = (IEnumerable <Team>)(controller.GetAllTeams() as ObjectResult).Value; List <Team> original = new List <Team>(teams); Guid id = Guid.NewGuid(); Team t = new Team("sample", id); var result = controller.CreateTeam(t); Team newTeam = new Team("sample2", id); controller.UpdateTeam(newTeam, id); var newTeamsRaw = (IEnumerable <Team>)(controller.GetAllTeams() as ObjectResult).Value; List <Team> newTeams = new List <Team>(newTeamsRaw); var sampleTeam = newTeams.FirstOrDefault(target => target.Name == "sample"); Assert.Null(sampleTeam); // sample is updated so should be null Team retrievedTeam = (Team)(controller.GetTeam(id) as ObjectResult).Value; Assert.Equal("sample2", retrievedTeam.Name); }
public async Task DeleteTeam_WhenTeamIsNotFound_ShouldReturnNotFoundResult() { // Arrange var teamRepository = A.Fake <ITeamRepository>(); Team?team = null; A.CallTo(() => teamRepository.GetTeamAsync(A <int> .Ignored)).Returns(team); var sharedRepository = A.Fake <ISharedRepository>(); var mapper = A.Fake <IMapper>(); var linkGenerator = A.Fake <LinkGenerator>(); var testController = new TeamsController(teamRepository, sharedRepository, mapper, linkGenerator); int id = 1; // Act var result = await testController.DeleteTeam(id); // Assert A.CallTo(() => teamRepository.GetTeamAsync(id)).MustHaveHappenedOnceExactly(); result.Result.ShouldBeOfType <NotFoundObjectResult>(); ((NotFoundObjectResult)result.Result).Value.ShouldBe($"Could not find team with ID of {id}"); }
public async void EditModelStateNotValidTest() { //Arrange var db = MockDb.CreateMockDb(); var c = new TeamsController(db); var teams = new Teams { Team_Mascot = "Otter", Team_Id = 2, Conference = "Eastern", Wins = 0, Loses = 0, Ties = 0, Win_Streak = 0 }; //Act await c.Create(teams); c.ModelState.AddModelError("Team_Name", "Required"); var r = await c.Edit(db.Teams.Find(2).Team_Id, teams); //Assert var result = Assert.IsType <ViewResult>(r); var model = Assert.IsAssignableFrom <Teams>(result.ViewData.Model); Assert.Equal(teams, model); }
public async Task PutTeam_WhenExceptionIsCaught_ShouldReturnInternalServerError() { // Arrange var teamRepository = A.Fake <ITeamRepository>(); A.CallTo(() => teamRepository.GetTeamAsync(A <int> .Ignored)).Throws <Exception>(); var sharedRepository = A.Fake <ISharedRepository>(); var mapper = A.Fake <IMapper>(); var linkGenerator = A.Fake <LinkGenerator>(); var testController = new TeamsController(teamRepository, sharedRepository, mapper, linkGenerator); int id = 1; var model = new TeamModel(); // Act var result = await testController.PutTeam(id, model); // Assert result.Result.ShouldBeOfType <ObjectResult>(); ((ObjectResult)result.Result).StatusCode.ShouldBe(StatusCodes.Status500InternalServerError); ((ObjectResult)result.Result).Value.ShouldBe("Database failure"); }
[TestMethod] //Pilot test public async Task Index_MultipleTeamsInDbWithEmptyString_ReturnsCorrectNumberOfTeams() { //Arrange var teams = new List <Team>() { new Team(), new Team(), new Team() }; var service = new Mock <ITeamRepository>(); service.Setup(x => x.GetTeams()).ReturnsAsync(teams); var controller = new TeamsController(service.Object); //Act var result = await controller.Index(String.Empty); //Assert var viewResult = (ViewResult)result; var model = ((ViewResult)result).Model as List <Team>; Assert.AreEqual(3, model.Count); }
/* void InitTeamController() { GameObject obj = GameObject.FindGameObjectWithTag("TeamsController"); if (obj) { teamCtrl = obj.GetComponent<TeamsController>(); } else { Debug.LogError("Cannot init team ctrl. Cannot find object."); } } */ public void LinkWithTeamCtrl(TeamsController tCtrl) { teamCtrl = tCtrl; }
public TeamsControllerTest() { teamrepo = new Mock <ITeamRepository>(); teamcontroller = new TeamsController(teamrepo.Object); }
/************************************************************ * Event Handlers ************************************************************/ void Awake() { _teamsController = TeamsController.Instance; }
private static IEnumerable <string> MakeTeams() { return(TeamsController.GetTeams().Select(Team => Team.Name)); }
public TeamsControllerTest() { _controller = new TeamsController(new WorldCupRepositoryFake()); AutoMapperConfig.Initialize(); }
public MemberControllerTests() { repository = new TestInMemoryTeamRepository(); teamController = new TeamsController(repository); memberController = new MemberController(repository); }
public void TestInitialize() { _mockCommandProcessor = new Mock<ICommandProcessor>(); _mockUserContext = new Mock<IUserContext>(); _mockTeamsViewModelBuilder = new Mock<ITeamsViewModelBuilder>(); _mockStreamItemsViewModelBuilder = new Mock<IStreamItemsViewModelBuilder>(); _mockProjectsViewModelBuilder = new Mock<IProjectsViewModelBuilder>(); _mockPostsViewModelBuilder = new Mock<IPostsViewModelBuilder>(); _mockMemberViewModelBuilder = new Mock<IMemberViewModelBuilder>(); _mockReferenceSpeciesViewModelBuilder = new Mock<IReferenceSpeciesViewModelBuilder>(); _documentStore = DocumentStoreHelper.StartRaven(); _controller = new TeamsController( _mockCommandProcessor.Object, _mockUserContext.Object, _mockTeamsViewModelBuilder.Object, _mockStreamItemsViewModelBuilder.Object, _mockProjectsViewModelBuilder.Object, _mockPostsViewModelBuilder.Object, _mockMemberViewModelBuilder.Object, _mockReferenceSpeciesViewModelBuilder.Object ); }
private void Start() { _teamsController = global::TeamsController.Instance; _teamMenuManager = global::TeamMenuManager.Instance; }
/************************************************************ * Event Handlers ************************************************************/ private void Awake() { _matchRoundMenuManager = global::MatchRoundMenuManager.Instance; _teamsController = global::TeamsController.Instance; _spawnController = global::SpawnController.Instance; _hudController = global::HUDController.Instance; _captureController = global::CaptureController.Instance; _userController = global::UserController.Instance; }
public TeamControllerTest() { controller = new TeamsController(new MemoryTeamRepository()); }
public static void Reset() { _instance = null; }
private void BindTeams() { using (TeamsController tc = new TeamsController()) { // if there is two teams with the same name, then we want to also say start/end date var currentTeams = tc.GetScopedEntities(CurrentUser.UserID, Permission).Where(i => i.ProgramID == SelectedProgramID.Value) .Where(i => TeamWhereClause == null ? true : TeamWhereClause(i)) .Select(i => new { Label = i.TeamName, Start = i.StartYear, End = i.EndYear, Value = i.TeamID, IsPresent = DateTime.Today <= i.EndYear.Date }) .GroupBy(i => i.Label).ToList(); var nonDuplicatedLabels = currentTeams.Where(i => i.Count() == 1).Select(i => i.First()); var duplicatedLabels = currentTeams.Where(i => i.Count() != 1).SelectMany(i => i.Select(j => new { Label = j.Label + string.Format(" ({0} to {1})", j.Start.ToString("MMM yyyy"), j.End.ToString("MMM yyyy")), Start = j.Start, End = j.End, Value = j.Value, IsPresent = j.IsPresent })); var teams = nonDuplicatedLabels.Union(duplicatedLabels).OrderByDescending(i => i.IsPresent).ThenBy(i => i.Start).ThenBy(i => i.Label).ToList(); ddlTeam.Reset(true); ddlTeam.DataSource = teams; ddlTeam.DataTextField = "Label"; ddlTeam.DataValueField = "Value"; ddlTeam.DataBind(); if (teams.Count() == 1) { ddlTeam.SelectedIndex = 1; ddlTeam_SelectedIndexChanged(null, null); } } }
protected void rptrTeamListing_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Image TeamLogoImage = (Image)e.Item.FindControl("TeamLogoImage"); Literal ltrlTeamImage = (Literal)e.Item.FindControl("ltrlTeamImage"); HyperLink hprTeamNameLink = (HyperLink)e.Item.FindControl("hprTeamNameLink"); HiddenField hdnTeamID = (HiddenField)e.Item.FindControl("hdnTeamID"); HyperLink team_sch_view = (HyperLink)e.Item.FindControl("team_sch_view"); HyperLink team_res_view = (HyperLink)e.Item.FindControl("team_res_view"); HyperLink team_roster_view = (HyperLink)e.Item.FindControl("team_roster_view"); HyperLink team_admin_view = (HyperLink)e.Item.FindControl("team_admin_view"); HyperLink team_gallerylink = (HyperLink)e.Item.FindControl("team_gallerylink"); HyperLink team_newslink = (HyperLink)e.Item.FindControl("team_newslink"); HyperLink team_videolink = (HyperLink)e.Item.FindControl("team_videolink"); int team_id = 0; int.TryParse(hdnTeamID.Value, out team_id); #region For Hyperlink Visibility TeamsController tm = new TeamsController(); DataTable tbcheckData = new DataTable(); //tbcheckData = tm.GetTeamScheduleAndResultsByCompetitionID(team_id); tbcheckData = tm.GetTeamFixturesByCompetitionID(team_id); if (tbcheckData.Rows.Count != 0) { team_sch_view.Visible = true; } tbcheckData = tm.GetTeamResultsByCompetitionID(team_id); if (tbcheckData.Rows.Count != 0) { team_res_view.Visible = true; } tbcheckData = tm.GetAllPlayersWithPosition(team_id, 5); if (tbcheckData.Rows.Count != 0) { team_roster_view.Visible = true; } tbcheckData = tm.GetManagementKeyDetailTeamID(team_id); if (tbcheckData.Rows.Count != 0) { team_admin_view.Visible = true; } tbcheckData = tm.GetTeamPhotoByTeamID(team_id); if (tbcheckData.Rows.Count != 0) { team_gallerylink.Visible = true; } tbcheckData = tm.GetTeamVideoAndOtherVideoPathByTeamID(team_id); if (tbcheckData.Rows.Count != 0) { team_videolink.Visible = true; } NewsDetailControl newsDetail = new NewsDetailControl(); tbcheckData = newsDetail.GetNewsByTeamId(team_id); if (tbcheckData.Rows.Count != 0) { team_newslink.Visible = true; } #endregion For Hyperlink Visibility team_sch_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=1"); team_res_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=2"); team_roster_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=4"); team_admin_view.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=3"); team_gallerylink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=7"); team_newslink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=5"); team_videolink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=6"); hprTeamNameLink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "", "mctl=" + "TeamAllDetail", "TeamID=" + team_id + "&TeamTabID=0"); if (!System.IO.File.Exists(Server.MapPath("DesktopModules\\SportSite\\" + TeamLogoImage.ImageUrl.ToString()))) { TeamLogoImage.Visible = false; ltrlTeamImage.Text = utFunctions.GetDefaultImage(hprTeamNameLink.Text, TeamLogoImage.Width.ToString()); } else { TeamLogoImage.Visible = true; ltrlTeamImage.Visible = false; } } }
public static void Run() { using (GraphClientManager manager = new GraphClientManager()) { Factory factory = new Factory(manager); ITrigger trigger = factory.GetTrigger(); ITeamsStructureExtractor teamsStructureExtractor = factory.GeTeamsStructureExtractor(); TeamsController teamsController = new TeamsController(); IEnumerable <string> channels = teamsStructureExtractor.GetChannels(); Thread.Sleep(100); IDictionary <string, IEnumerable <FileInfo> > channelDocDictionary = teamsStructureExtractor.GetChannelDocumentsDictionary(); Thread.Sleep(100); IDictionary <string, IEnumerable <TeamsApp> > channelAppDictionary = teamsStructureExtractor.GetChannelAppsDictionary(); Thread.Sleep(100); foreach (string groupId in trigger.GetNewTeamsGroupIds()) { try { teamsController.CreatedTeamsFromGroupidAsync(groupId, manager.GetGraphHttpClient()).GetAwaiter().GetResult(); Thread.Sleep(100); IEnumerable <AADIdentity> existedChannels = teamsController.GetChannels(groupId, manager.GetGraphHttpClient()).GetAwaiter().GetResult(); Thread.Sleep(100); foreach (string channelName in channels) { if (string.IsNullOrWhiteSpace(channelName)) { continue; } string channelId = string.Empty; if (channelName.Equals(DefaultChannelName, StringComparison.InvariantCultureIgnoreCase)) { channelId = existedChannels.FirstOrDefault(x => x.DisplayName.Equals(DefaultChannelName, StringComparison.InvariantCultureIgnoreCase))?.Id; } else { channelId = teamsController.CreateChannelAsync(groupId, channelName, manager.GetGraphHttpClient()) .GetAwaiter().GetResult(); Thread.Sleep(100); } if (channelDocDictionary.ContainsKey(channelName)) { foreach (FileInfo file in channelDocDictionary[channelName]) { teamsController.UploadFileAsync(groupId, channelName, File.ReadAllBytes(file.FullName), file.Name, manager.GetGraphHttpClient()).GetAwaiter().GetResult(); Thread.Sleep(100); } } if (channelAppDictionary.ContainsKey(channelName)) { foreach (TeamsApp app in channelAppDictionary[channelName]) { teamsController .AddCustomTabAsync(groupId, channelId, app, manager.GetGraphHttpClient()) .GetAwaiter().GetResult(); Thread.Sleep(100); } } } } catch (AutoTeamsStructureException e) { if (e.Message.Contains("Team already exists")) { Console.WriteLine($"Teams team for group {groupId} already created, skip."); } else { throw; } } } } }
public override void EstablishContext() { repository = new Mock<IRepository>(); authService = AuthHelper.CreateMockAuthenticationService(); controller = new TeamsController(repository.Object, authService); }
public TeamsControllerTests() { repository = Substitute.For <ITeamRepository>(); logger = Substitute.For <ILogger <TeamsController> >(); controller = new TeamsController(repository, logger); }
private void SetupControllerContext(TeamsController sut) { sut.ControllerContext = new ControllerContext(_httpContextMock.Object, new RouteData(), sut); }
protected override void Handle() { TeamsController.AssignTeamsClient(Reader); }