public async Task ShouldCreateObjectWithoutHelper() { // Arrange await SchemaHelper.CreateSchemasIfNotExistentAsync <Person>(_client).ConfigureAwait(false); var originalPlayer = new SoccerPlayer { BirthDate = DateTime.Now, EmailAddress = "*****@*****.**", Firstname = "Urs", LastName = "Brogle" }; // Act var createRequest = new ListItemCreateRequest { ContentSchemaId = nameof(SoccerPlayer), Content = originalPlayer }; var playerItem = await _client.ListItem.CreateAsync(createRequest, new[] { ListItemResolveBehavior.Content }).ConfigureAwait(false); // Assert Assert.NotNull(playerItem); var createdPlayer = playerItem.ConvertTo <SoccerPlayer>(); Assert.Equal("Urs", createdPlayer.Firstname); }
public virtual void OnEnterState() { if (_sp == null) { _sp = GetComponent <SoccerPlayer>(); } }
public void Update(SoccerPlayer player) { if (money >= player.GetCost()) { Console.WriteLine("Club " + name + " can buy player " + player.Name()); } }
public IEnumerator WHEN_BallsKicked_THEN_BallPositionsDoNotChange() { // Wait for soccer player to load, kick ball, and then ball to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); BallProjectile[] balls = Object.FindObjectsOfType <BallProjectile>(); BallProjectile ball1 = balls[0]; BallProjectile ball2 = balls[1]; float endingTime = Time.time + Math.Max(ball1.ActualTimeToContact, ball2.ActualTimeToContact); float currentTime = Time.time; Vector3 ball1StartingPosition = ball1.transform.position; Vector3 ball2StartingPosition = ball2.transform.position; // For every frame before the last ball arrives, their positions should be // unchanged. while (endingTime - currentTime > 0) { Assert.AreEqual(ball1StartingPosition, ball1.transform.position); Assert.AreEqual(ball2StartingPosition, ball2.transform.position); yield return(new WaitForSeconds(0.05f)); currentTime = Time.time; } }
/// <summary> /// Searches for and then returns a list of /// type AdjustedTransaction, filtered by the incoming search filter /// </summary> /// <param name="teamId"></param> /// <returns>A list of adjustment type (datacontract)</returns> public SoccerTeam FetchTeam <T>(long teamId) { var soccerTeam = new SoccerTeam(); using (var connection = new SqlConnection(ConnectionString)) { var command = new SqlCommand("V", connection) { CommandType = CommandType.Text, CommandText = String.Format("SELECT * FROM V_TEAM_PLAYERS WHERE TEAM_ID = {0}", teamId) }; connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { soccerTeam.Name = reader["TEAM_NAME"].ToString(); var player = new SoccerPlayer { FirstName = reader["FIRST_NAME"].ToString(), LastName = reader["LAST_NAME"].ToString() }; soccerTeam.AddPlayer(player); } } } return(soccerTeam); }
public IEnumerator WHEN_BallKickedAndRightBallKeyPressed_THEN_GloveMovesHorizontallyRightToTargetRing() { GameObject rightTargetRing = GameObject.Find("Canvas").transform.Find("RightTargetRing").gameObject; foreach (var _ in Enumerable.Range(1, SaveOneBall.NUMBER_OF_ROUNDS)) { // Wait for soccer player to load, kick ball, and then ball to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); GameObject glove = GameObject.Find("Glove"); Assert.False(glove.transform.position.Equals(rightTargetRing.transform.position.x)); Press(keyboard[SaveOneBall.RIGHT_BALL_KEY]); yield return(new WaitForSeconds( CatchTheBall.SECONDS_FOR_GLOVES_TO_MOVE + 0.5F * CatchTheBall.SECONDS_FOR_GLOVES_TO_REMAIN_IDLE )); Assert.AreEqual(rightTargetRing.transform.position.x, glove.transform.position.x, 0.1F); } }
public async Task ShouldCreateObjectWithoutHelper() { /// Arrange var originalPlayer = new SoccerPlayer { BirthDate = DateTime.Now, EmailAddress = "*****@*****.**", Firstname = "Urs", LastName = "Brogle" }; /// Act var createRequest = new ListItemCreateRequest { ContentSchemaId = "SoccerPlayer", Content = originalPlayer }; var playerItem = await _client.ListItems.CreateAsync(createRequest); /// Assert Assert.NotNull(playerItem); var createdPlayer = playerItem.ConvertTo <SoccerPlayer>("SoccerPlayer"); Assert.Equal("Urs", createdPlayer.Firstname); }
public IEnumerator ActualTimeToContactAndInitialRadiusOfBallIsRandom() { ISet <float> actualTimesToContact = new HashSet <float>(); ISet <float> ballInitialRadiuses = new HashSet <float>(); foreach (var i in Enumerable.Range(1, JudgeTheBall.NUMBER_OF_ROUNDS)) { // Wait for soccer players to load, kick balls, and then balls to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); foreach (BallProjectile ball in Object.FindObjectsOfType <BallProjectile>()) { actualTimesToContact.Add(ball.ActualTimeToContact); ballInitialRadiuses.Add(ball.BallInitialRadius); } yield return(new WaitUntil(() => Object.FindObjectOfType <Button>() != null)); Button submitButton = Object.FindObjectOfType <Button>(); submitButton.onClick.Invoke(); } int numberOfUniqueActualTimesToContact = actualTimesToContact.Count; int numberOfUniqueBallInitialRadiuses = ballInitialRadiuses.Count; Assert.AreNotEqual(1, numberOfUniqueActualTimesToContact); Assert.AreNotEqual(1, numberOfUniqueBallInitialRadiuses); }
public void TestGender() { SoccerPlayer sp = new SoccerPlayer("Fergie", 22, Gender.Female, Position.Goalkeeper); SoccerTeam st = new SoccerTeam("Team 1", Gender.Male, 18); st.AddPlayer(sp); }
public IEnumerator ActualTimeToContactAndInitialRadiusOfBallIsRandom() { LogAssert.ignoreFailingMessages = true; ISet <float> actualTimesToContact = new HashSet <float>(); ISet <float> ballInitialRadiuses = new HashSet <float>(); foreach (var i in Enumerable.Range(1, SaveOneBall.NUMBER_OF_ROUNDS)) { // Wait for soccer players to load, kick balls, and then balls to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); foreach (BallProjectile ball in Object.FindObjectsOfType <BallProjectile>()) { actualTimesToContact.Add(ball.ActualTimeToContact); ballInitialRadiuses.Add(ball.BallInitialRadius); } Press(keyboard.aKey); } int numberOfUniqueActualTimesToContact = actualTimesToContact.Count; int numberOfUniqueBallInitialRadiuses = ballInitialRadiuses.Count; Assert.AreNotEqual(1, numberOfUniqueActualTimesToContact); Assert.AreNotEqual(1, numberOfUniqueBallInitialRadiuses); }
public void TestIndexer() { SoccerPlayer m1 = new SoccerPlayer("Tom", 12, Gender.Male, Position.Goalkeeper); SoccerPlayer m2 = new SoccerPlayer("Sam", 12, Gender.Male, Position.Defender); SoccerPlayer m3 = new SoccerPlayer("Fergie", 12, Gender.Male, Position.Goalkeeper); SoccerTeam pl = new SoccerTeam("Team 1", Gender.Male, 18); pl.AddPlayer(m1); pl.AddPlayer(m2); pl.AddPlayer(m3); List <SoccerPlayer> team = new List <SoccerPlayer>(); team.Add(m1); // Indexer adding based on name List <SoccerPlayer> nameList = new List <SoccerPlayer>(); foreach (SoccerPlayer m in pl) { if (m.Name == "Tom") { nameList.Add(m); } else { break; } } // checks both lists are equal CollectionAssert.AreEqual(team, nameList); }
public IEnumerator WHEN_BallKicked_THEN_BallPositionDoesNotChange() { // Wait for soccer player to load, kick ball, and then ball to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); BallProjectile ball = Object.FindObjectOfType <BallProjectile>(); Vector3 startingPosition = ball.transform.position; float endingTime = Time.time + ball.ActualTimeToContact; float currentTime = Time.time; // For every frame before the ball arrives, its position should be // unchanged. while (endingTime - currentTime > 0) { Assert.AreEqual(startingPosition, ball.transform.position); yield return(new WaitForSeconds(0.05f)); currentTime = Time.time; } }
public void TestAddPlayer2() { SoccerPlayer sp1 = new SoccerPlayer("Fergie", 12, Gender.Male, Position.Goalkeeper); SoccerTeam st = new SoccerTeam("Team 1", Gender.Male, 18); st.AddPlayer(sp1); st.AddPlayer(sp1); }
public HasBall(SoccerPlayer player, TeamManagement team, BallGoal ballGoal, Rigidbody2D ball) { _player = player; _team = team; _goal = ballGoal; _ball = ball; ballPredictor = _ball.GetComponent <PhysicsPredictor>(); }
public void TestValidation2() { SoccerPlayer sp = new SoccerPlayer("Fergie", 22, Gender.Male, Position.Goalkeeper); Assert.AreEqual(sp.Name, "Fergie"); Assert.AreEqual(sp.Age, 22); Assert.AreEqual(sp.Gender, Gender.Male); Assert.AreEqual(sp.Position, Position.Goalkeeper); }
public void TestValidation1() { SoccerPlayer sp = new SoccerPlayer(); Assert.AreEqual(sp.Name, ""); Assert.AreEqual(sp.Age, 0); Assert.AreEqual(sp.Gender, Gender.Male); Assert.AreEqual(sp.Position, Position.Defender); }
public SoccerPlayerDetailsViewModel(SoccerPlayer player, CollectionFactory collections, IChangeManager changesManager) { Collections = collections; _changesManager = changesManager; _playerModel = player; Player = new SoccerPlayerViewModel(player); }
public IEnumerator BallMovesAtConstantVelocity() { // Wait for soccer player to load, kick ball, and then ball to be spawned yield return(new WaitUntil(() => Object.FindObjectOfType <SoccerPlayer>() != null)); SoccerPlayer soccerPlayer = Object.FindObjectOfType <SoccerPlayer>(); yield return(new WaitUntil(() => soccerPlayer.PlayerHasKickedBall())); yield return(new WaitUntil(() => Object.FindObjectOfType <BallProjectile>() != null)); BallProjectile ball = Object.FindObjectOfType <BallProjectile>(); Vector3 startingPosition = ball.transform.position; float endingTime = Time.time + ball.ActualTimeToContact; float currentTime = Time.time; // For every frame before the ball arrives, its position should be // unchanged. List <double> ballScales = new List <double>(); while (endingTime - currentTime > 0) { ballScales.Add(ball.transform.localScale.x); yield return(new WaitForSeconds(0.05f)); currentTime = Time.time; } // Utility method for calculating standard deviation // Credit: https://stackoverflow.com/a/6252351 double StandardDeviation(IEnumerable <double> values) { double avg = values.Average(); return(Math.Sqrt(values.Average(v => Math.Pow(v - avg, 2)))); } // Find the absolute difference between two any // ball scales. IEnumerable <double> ballScaleDifferences = Enumerable.Zip(ballScales, ballScales.Skip(1), (x1, x2) => Math.Abs(x2 - x1)); // If the data is linear, then // (ballScale(i+1) - ballScale(i)) = (ballScale(j+1) - ballScale(j)) // for any frame i and j. Thus, we can take the standard deviation // of the ball scale differences. If it is close to 0, then // the ball scale differences are all almost the same, thus indicating // a linear relationship. double standardDeviation = StandardDeviation(ballScaleDifferences); // Check if the standard deviation is equal to 0 with a possible error // of ± 0.1. Assert.AreEqual(0, standardDeviation, 0.1); }
public Test() { // create some players rooney = new SoccerPlayer { Name = "Wayne Rooney", Age = 26, Gender = Gender.Male, Position = SoccerPosition.Striker }; rio = new SoccerPlayer { Name = "Rio Ferdinand", Age = 33, Gender = Gender.Male, Position = SoccerPosition.Defender }; }
//public SoccerPlayer OriginalBallValues { get; set; } public SoccerPlayerArgs(SoccerPlayer playerValues, ChangeType type, ColumnName?column = null, SoccerPlayer originalPlayerValues = null) : base(type) { PlayerValues = playerValues; if (column.HasValue) { Column = column.Value; } //if (originalPlayerValues != null) OriginalBallValues = originalPlayerValues; }
public void TestAddPlayer1() { SoccerPlayer sp1 = new SoccerPlayer("Fergie", 12, Gender.Male, Position.Goalkeeper); SoccerPlayer sp2 = new SoccerPlayer("Sam", 12, Gender.Male, Position.Defender); SoccerTeam st = new SoccerTeam("Team 1", Gender.Male, 18); st.AddPlayer(sp1); st.AddPlayer(sp2); CollectionAssert.Contains(st.Players, sp1); CollectionAssert.Contains(st.Players, sp2); }
public void Test3() { SoccerPlayer rooney1 = new SoccerPlayer { Name = "Wayne Rooney", Age = 26, Gender = Gender.Male, Position = SoccerPosition.Striker }; SoccerPlayer rooney2 = new SoccerPlayer { Name = "Wayne Rooney", Age = 26, Gender = Gender.Male, Position = SoccerPosition.Striker }; Assert.AreEqual(rooney1, rooney2); }
public void CanMapFromFootballToSoccer() { var config = new SportMappingConfiguration(); config.Configure(); var mapper = new AutoMapperMappingService(); var soccer = new SoccerPlayer { Name = "Fozzy" }; var mapped = mapper.Map<SoccerPlayer, FootballPlayer>(soccer); Assert.Equal("Fozzy", mapped.Name); }
public void Setup() { // create some players rooney = new SoccerPlayer { Name = "Wayne Rooney", Age = 26, Gender = Gender.Male, Position = SoccerPosition.Striker }; rio = new SoccerPlayer { Name = "Rio Ferdinand", Age = 33, Gender = Gender.Male, Position = SoccerPosition.Defender }; berbatov = new SoccerPlayer { Name = "Dimitar Berbatov", Age = 33, Gender = Gender.Male, Position = SoccerPosition.Striker }; }
public EditableCellViewModel(object value, IChangeManager changeManager, ColumnName?column = null, SoccerPlayer player = null, bool isEnabled = true) : base(value) { _changeManager = changeManager; IsEnabled = isEnabled; if (player != null) { _player = player; } if (column.HasValue) { _column = column; } }
static public void Run() { Console.WriteLine("------------Observer------------"); Club mu = new Club("Manchester United", 150); Club cl = new Club("Chelsea", 100); Club ju = new Club("Juventus", 70); SoccerPlayer messi = new SoccerPlayer("Messi"); messi.RegisterObserver(mu); messi.RegisterObserver(cl); messi.RegisterObserver(ju); messi.SetCost(90); }
/// <summary> /// Creates a kicking soccer player at the specified ball position. /// </summary> /// <param name="ballPosition">The position where the player will kick.</param> /// <param name="initialBallRadius">The radius of the ball initially.</param> /// <returns>The created soccer player object.</returns> public SoccerPlayer InstantiateSoccerPlayer(Vector3 ballPosition, float initialBallRadius) { SoccerPlayer player = Instantiate(SoccerPlayerPrefab, ballPosition, Quaternion.identity).GetComponent <SoccerPlayer>(); // This number is used to determine how big the player should // appear relative to the ball. This number was obtained by seeing // what looked good in gameplay, but can be modified as you see fit. float playerToBallScale = initialBallRadius / 30; player.transform.localScale = new Vector3(playerToBallScale, playerToBallScale, playerToBallScale); return(player); }
public void CanMapFromFootballToSoccer() { var config = new SportMappingConfiguration(); config.Configure(); var mapper = new AutoMapperMappingService(); var soccer = new SoccerPlayer { Name = "Fozzy" }; var mapped = mapper.Map <SoccerPlayer, FootballPlayer>(soccer); Assert.Equal("Fozzy", mapped.Name); }
public override IEnumerator StartRound() { BallRound ballRound = GenerateDataForRound(ballStorage.TargetRadius); Vector3 leftBallPosition = LeftTargetRing.transform.position; Vector3 rightBallPosition = RightTargetRing.transform.position; SoccerPlayer leftSoccerPlayer = InstantiateSoccerPlayer(leftBallPosition, ballRound.InitialLeftBallRadius); SoccerPlayer rightSoccerPlayer = InstantiateSoccerPlayer(rightBallPosition, ballRound.InitialRightBallRadius); yield return(new WaitUntil(() => leftSoccerPlayer.PlayerHasKickedBall() && rightSoccerPlayer.PlayerHasKickedBall() )); BallProjectile leftBallProjectile = InstantiateBallProjectile(leftBallPosition, ballStorage.TargetRadius, ballRound.InitialLeftBallRadius, ballRound.LeftActualTimeToContact, // Ball doesn't disappear in Save One Ball ballTimeBeforeDisappearance: null ); BallProjectile rightBallProjectile = InstantiateBallProjectile(rightBallPosition, ballStorage.TargetRadius, ballRound.InitialRightBallRadius, ballRound.RightActualTimeToContact, // Ball doesn't disappear in Save One Ball ballTimeBeforeDisappearance: null ); // Record the time at which the "kick" takes place float beginTime = Time.time; // Make round end when the user hits any // key, or when they have waited too long (2 times the actual // time to contact) yield return(StartCoroutine( WaitForInputOrTimeExpires( beginTime: beginTime, maxTimeToWait: 2 * Math.Min(ballRound.LeftActualTimeToContact, ballRound.RightActualTimeToContact), inputReceived: () => Keyboard.current[LEFT_BALL_KEY].isPressed || Keyboard.current[RIGHT_BALL_KEY].isPressed, ballProjectiles: new List <BallProjectile> { leftBallProjectile, rightBallProjectile }, ballRound: ballRound ) )); }
public async Task ShouldUpdateMany() { // Arrange await SchemaHelper.CreateSchemasIfNotExistentAsync <SoccerPlayer>(_client).ConfigureAwait(false); var originalPlayer = new SoccerPlayer { BirthDate = DateTime.Now, EmailAddress = "*****@*****.**", Firstname = "Test", LastName = "Soccerplayer" }; var createRequest = new ListItemCreateRequest { ContentSchemaId = nameof(SoccerPlayer), Content = originalPlayer }; var playerItem = await _client.ListItem.CreateAsync(createRequest, new[] { ListItemResolveBehavior.Content }).ConfigureAwait(false); // Act var player = playerItem.ConvertTo <SoccerPlayer>(); player.Firstname = "xy jviorej ivorejvioe"; await _client.ListItem.UpdateManyAsync(new ListItemUpdateManyRequest { AllowMissingDependencies = false, Items = new[] { new ListItemUpdateItem() { Id = playerItem.Id, Content = player } } }).ConfigureAwait(false); var updatedPlayer = await _client.ListItem.GetAndConvertToAsync <SoccerPlayer>(playerItem.Id, nameof(SoccerPlayer)).ConfigureAwait(false); // Assert Assert.Equal(player.Firstname, updatedPlayer.Firstname); }
public async Task ShouldUpdateMany() { /// Arrange var originalPlayer = new SoccerPlayer { BirthDate = DateTime.Now, EmailAddress = "*****@*****.**", Firstname = "Test", LastName = "Soccerplayer" }; var createRequest = new ListItemCreateRequest { ContentSchemaId = "SoccerPlayer", Content = originalPlayer }; var playerItem = await _client.ListItems.CreateAsync(createRequest); /// Act var player = playerItem.ConvertTo <SoccerPlayer>(nameof(SoccerPlayer)); player.Firstname = "xy jviorej ivorejvioe"; var businessProcess = await _client.ListItems.UpdateManyAsync(new ListItemUpdateManyRequest { AllowMissingDependencies = false, Requests = new[] { new ListItemUpdateRequest { Id = playerItem.Id, Content = player } } }); await _client.BusinessProcesses.WaitForCompletionAsync(businessProcess.Id); var updatedPlayer = await _client.ListItems.GetAndConvertToAsync <SoccerPlayer>(playerItem.Id, nameof(SoccerPlayer)); /// Assert Assert.Equal(player.Firstname, updatedPlayer.Firstname); }