public void GenerateMessage_GivenImplementationLevelHasFallenAndPlayerTestStateIsRed_ShouldReturnBrokenTestMessage()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor(showHint: true);
            var playerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Red"
            };
            var previousResult   = CreateResult(4, 6, false, playerFeedback: playerFeedback);
            var result           = CreateResult(3, 6, false, playerFeedback: playerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(previousResult);
            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var feedbackMessage = processor.CreateFeedback(attemptGameState);
            //---------------Test Result -----------------------
            var expected = "A test that was previously passing has broken! Perhaps undo the change you made and try again, or try and see why the test broke.";

            Assert.AreEqual(expected, feedbackMessage.Message);
        }
        public void GenerateMessage_GivenImplementationLevelIsGTPrevious_ShouldReturnProgressMessage()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor(showHint: true);
            var playerFeedback = new PlayerFeedback
            {
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Red"
            };
            var previousResult   = CreateResult(4, 6, false, playerFeedback: playerFeedback);
            var result           = CreateResult(5, 6, false, playerFeedback: playerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(previousResult);
            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var message = processor.GenerateMessage(attemptGameState);
            //---------------Test Result -----------------------
            var expected = "Good";

            Assert.AreEqual(expected, message);
        }
Exemple #3
0
 private void LogPlayerFeedback(PlayerFeedbackEvent playerFeedbackEvent)
 {
     try
     {
         var playerConfig       = _scenario.Configuration.PlayerConfiguration.SingleOrDefault(pc => pc.ExternalId == playerFeedbackEvent.PlayerExternalId);
         var rankedPlayerConfig = _scenario.Configuration.PlayerConfiguration.SingleOrDefault(pc => pc.ExternalId == playerFeedbackEvent.RankedPlayerExternalId);
         if (playerConfig != null && rankedPlayerConfig != null)
         {
             var player       = _context.InstancePlayers.Find(_game.Id, playerConfig.Id);
             var rankedPlayer = _context.InstancePlayers.Find(_game.Id, rankedPlayerConfig.Id);
             if (player != null && rankedPlayer != null)
             {
                 var playerFeedback = new PlayerFeedback()
                 {
                     Player            = player,
                     RankedPlayer      = rankedPlayer,
                     LeadershipRank    = playerFeedbackEvent.PlayerRankings[0],
                     CommunicationRank = playerFeedbackEvent.PlayerRankings[1],
                     CooperationRank   = playerFeedbackEvent.PlayerRankings[2],
                 };
                 _context.PlayerFeedback.Add(playerFeedback);
             }
         }
     }
     catch (Exception ex)
     {
         // TODO: log
     }
 }
        public void GenerateMessage_GivenPreviousResultIsGreenAndCurrentResultIsGreen_ShouldReturnProgressMessage()
        {
            //---------------Set up test pack-------------------
            var processor             = CreateAnalysisResultProcessor();
            var currentPlayerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Green"
            };
            var previousPlayerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle negative numbers",
                PlayerTestState = "Player Test State: Green"
            };
            var result           = CreateResult(4, 7, false, playerFeedback: currentPlayerFeedback);
            var previousResult   = CreateResult(3, 6, false, playerFeedback: previousPlayerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(previousResult);
            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var feedbackMessage = processor.CreateFeedback(attemptGameState);
            //---------------Test Result -----------------------
            const string expected = "You are not allowed to write any production code unless it is to make a failing unit test pass. Please undo or comment out your implementation for your test and run your tests";

            Assert.AreEqual(expected, feedbackMessage.Message);
        }
        public void CreateFeedback_GivenPreviousResultIsGreenAndCurrentResultIsRed_ShouldReturnProgressMessage()
        {
            //---------------Set up test pack-------------------
            var processor             = CreateAnalysisResultProcessor();
            var currentPlayerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Red"
            };
            var previousPlayerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle negative numbers",
                PlayerTestState = "Player Test State: Green"
            };
            var result           = CreateResult(2, 3, false, "Red", currentPlayerFeedback);
            var previousResult   = CreateResult(1, 2, false, "Green", previousPlayerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(previousResult);
            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var feedbackMessage = processor.CreateFeedback(attemptGameState);
            //---------------Test Result -----------------------
            const string expected = "You have written a test without having a failing test for your previous implementation. Please undo or comment out your test and the implementation for your previous test and run your tests";

            Assert.AreEqual(expected, feedbackMessage.Message);
        }
Exemple #6
0
        private string CreateJsonObject(PlayerImplementationRunResult playerImplementationRunResult,
                                        PlayerTestsRunResult playerTestsRunResult,
                                        PlayerFeedback playerFeedback,
                                        string attemptName,
                                        IKataraiApp kataraiApp,
                                        string playerPath,
                                        IFileSystem fileSystem)
        {
            var attemptCreationTime = GetAttemptCreationTime(attemptName);

            var kataStartTime = GetKataStartTime(attemptCreationTime, kataraiApp);

            return(JsonConvert.SerializeObject(new
            {
                userName = GetUserName(),
                attemptName,
                timestamp = GetTimestamp(),
                attemptCreationTime,
                kataStartTime,
                playerImplementationRunResult,
                playerTestsRunResult,
                overallAnalysisResult = playerFeedback,
                appVersion = GetAppVersion(),
                kataName = _kataHelper.GetKataName(attemptName),
                kata = GetKataFilesContents(playerPath, fileSystem)
            }, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
 void Start()
 {
     interactableLayerMask = ((1 << enemyLayer) | (1 << interactablesLayer));
     pUI       = GetComponent <AirTankController>();
     pCon      = GetComponent <PlayerController>();
     pFeedback = GetComponent <PlayerFeedback>();
     pAudio    = GetComponent <PlayerAudioController>();
     animator  = pCon.animator;
 }
Exemple #8
0
    protected override void Start()
    {
        base.Start();

        pFeedback = GetComponent <PlayerFeedback>();
        pAudio    = GetComponent <PlayerAudioController>();
        pHealth   = GetComponent <PlayerHealthSystem>();

        groundLayerMask = ((1 << groundLayer)) | ((1 << breakableFloorsLayer)) | ((1 << slidingSurfaceLayer)) | ((1 << breakableObjectsLayer)) | ((1 << rollingObjectsLayer));
        wallLayerMask   = ((1 << groundLayer)) | ((1 << breakableFloorsLayer)) | ((1 << breakableObjectsLayer));
    }
Exemple #9
0
    /// <summary>
    /// Funció que impedeix la mecanica de drag mentre no hagui passat el temps de cooldown
    /// </summary>
    /// <param name="s">Temps a esperar antes de permetrer el salt</param>
    /// <returns></returns>
    public IEnumerator DragCooldown(float s)
    {
        yield return(new WaitForSeconds(s));

        drag_feedback.Play();
        canDrag = true;
        PlayerFeedback.Drag(this);

        breakRock  = false;
        breakLiana = false;
        killEnemy  = false;
    }
    void Start()
    {
        pCon      = GetComponent <PlayerController>();
        pAudio    = GetComponent <PlayerAudioController>();
        pFeedback = GetComponent <PlayerFeedback>();
        pInteract = GetComponent <PlayerHandleInteract>();
        windDial  = Toolbox.GetInstance().GetPlayerManager().GetWindDial();
        animator  = GetComponent <Animator>();

        currentPhase           = hurtPhase0;
        healthNodeFlashRoutine = IInjuredFlashRed();
    }
Exemple #11
0
            public void ResultError_WhenRatingIsOutOfRange(int rating)
            {
                var feedbackCreationResult = PlayerFeedback.Create(_sessionId, _playerId, rating, comment, timestamp);

                var expectedError = new Error
                {
                    Type    = ErrorType.RatingOutOfRange.ToString(),
                    Message = ErrorMessage.RatingOutOfRangeMessage
                };

                Assert.True(feedbackCreationResult.IsError);
                Assert.Equal(expectedError, feedbackCreationResult.Error);
            }
        public void GenerateHint_GivenResultWithEmptyHint_ShouldReturnEmptyString()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor();
            var playerFeedback = new PlayerFeedback {
                Hint = ""
            };
            var result = new Result(3, 6, playerFeedback);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var hint = processor.GenerateHint(result);

            //---------------Test Result -----------------------
            Assert.AreEqual(string.Empty, hint);
        }
        public void GenerateDebugInfo_GivenResultWithDebugInfo_ShouldReturnDebugInfo()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor();
            var playerFeedback = new PlayerFeedback {
                DebugInfo = "L=1, T=5, and whatever else"
            };
            var result = new Result(3, 6, playerFeedback);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var debugInfo = processor.GenerateDebugInfo(result);

            //---------------Test Result -----------------------
            Assert.AreEqual("L=1, T=5, and whatever else", debugInfo);
        }
        public void GenerateDebugInfo_GivenResultWithNullDebugInfo_ShouldReturnEmptyString()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor();
            var playerFeedback = new PlayerFeedback {
                DebugInfo = null
            };
            var result = new Result(3, 6, playerFeedback);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var debugInfo = processor.GenerateDebugInfo(result);

            //---------------Test Result -----------------------
            Assert.AreEqual(string.Empty, debugInfo);
        }
        public void GenerateHint_GivenResultWithHint_ShouldReturnHint()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor();
            var playerFeedback = new PlayerFeedback {
                Hint = "Return the negative number in exception"
            };
            var result = new Result(3, 6, playerFeedback);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var hint = processor.GenerateHint(result);
            //---------------Test Result -----------------------
            var expected = "Return the negative number in exception";

            Assert.AreEqual(expected, hint);
        }
Exemple #16
0
            public void ReturnOk_WhenValidPropertiesAreGiven()
            {
                var rating = 5;
                var feedbackCreationResult = PlayerFeedback.Create(_sessionId, _playerId, rating, comment, timestamp);

                var expectedFeedback = new PlayerFeedback
                {
                    SessionId = _sessionId,
                    PlayerId  = _playerId,
                    Rating    = rating,
                    Comment   = comment,
                    Timestamp = timestamp
                };

                Assert.True(feedbackCreationResult.IsOk);
                Assert.Equal(expectedFeedback, feedbackCreationResult.Value);
            }
Exemple #17
0
        public void Log(PlayerImplementationRunResult playerImplementationRunResult,
                        PlayerTestsRunResult playerTestsRunResult,
                        PlayerFeedback playerFeedback,
                        IKataraiApp kataraiApp,
                        IFileSystem fileSystem)
        {
            var playerPath  = GetPlayerPath(kataraiApp);
            var attemptName = GetAttemptName(playerPath);

            if (!attemptName.Contains("-"))
            {
                return;
            }
            var jsonObject = CreateJsonObject(playerImplementationRunResult, playerTestsRunResult, playerFeedback, attemptName, kataraiApp, playerPath, fileSystem);

            _splunkAppender.Log(jsonObject, "katarai");
        }
Exemple #18
0
        public async Task <Result> Send(PlayerFeedbackDto feedback)
        {
            var feedbackValidation =
                PlayerFeedback.Create(
                    feedback.SessionId,
                    feedback.PlayerId,
                    feedback.Rating,
                    feedback.Comment,
                    feedback.Timestamp
                    );

            if (!feedbackValidation.IsOk)
            {
                return(Result.Fail(feedbackValidation.Error));
            }

            await _messageSender.Send(AddPlayerFeedbackMessage.CreateFromDomain(feedbackValidation.Value));

            return(Result.Ok());
        }
        public void CreateFeedback_GivenKataTimerHasNotStarted_ShouldReturnProgressMessage()
        {
            //---------------Set up test pack-------------------
            var processor             = CreateAnalysisResultProcessor();
            var currentPlayerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Red"
            };
            var result           = CreateResult(2, 3, false, "Red", currentPlayerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var feedbackMessage = processor.CreateFeedback(attemptGameState);
            //---------------Test Result -----------------------
            const string expected = "The timer has not started. If you have the default constructor test that comes with solution, please ensure that you build the solution before writing your first test";

            Assert.AreEqual(expected, feedbackMessage.Message);
        }
        public void GenerateMessage_GivenIsShowHintOnIsTrue_ShouldReturnProgressMessageWithHint()
        {
            //---------------Set up test pack-------------------
            var processor      = CreateAnalysisResultProcessor(showHint: true);
            var playerFeedback = new PlayerFeedback
            {
                Hint            = "My Hint",
                Progress        = "Good",
                DebugInfo       = "single custom debug",
                StepShouldDo    = "Handle a single custom delimiter",
                PlayerTestState = "Player Test State: Red"
            };
            var result           = CreateResult(3, 6, false, playerFeedback: playerFeedback);
            var attemptGameState = CreateAttemptGameState();

            attemptGameState.SetLatestResult(result);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var message = processor.GenerateMessage(attemptGameState);
            //---------------Test Result -----------------------
            var expected = "Good" + Environment.NewLine + "Hint:" + Environment.NewLine + "My Hint";

            Assert.AreEqual(expected, message);
        }
 void Start()
 {
     _instance            = this;
     _canvasRectTransform = GetComponent <RectTransform>();
 }
Exemple #22
0
 public ResultFake(PlayerImplementationRunResult playerImplementationRunResult, PlayerTestsRunResult playerTestsRunResult, PlayerFeedback playerFeedback)
     : base(playerImplementationRunResult, playerTestsRunResult, playerFeedback)
 {
 }
Exemple #23
0
 public ResultFake(int playerImplementationlevel, int playerTestLevel, PlayerFeedback playerFeedback)
     : base(playerImplementationlevel, playerTestLevel, playerFeedback)
 {
 }
Exemple #24
0
    // <<--------------------------------------------- SET UP PLAYER FEEDBACK ------------------------------------------- >> //

    public void SetPlayerFeedback(PlayerFeedback _pFeedback)
    {
        pFeedback = _pFeedback;
    }
 private Result CreateResult(int implementationLevel, int testLevel, bool kataCompleted, string testState = null, PlayerFeedback playerFeedback = null)
 {
     testState      = testState ?? "Green";
     playerFeedback = playerFeedback ?? new PlayerFeedback {
         PlayerTestState = "Player Test State: " + testState, KataCompleted = kataCompleted
     };
     return(new Result(
                new PlayerImplementationRunResult {
         Level = implementationLevel, StepShouldDo = "Do Level " + implementationLevel
     },
                new PlayerTestsRunResult {
         Level = testLevel
     },
                playerFeedback));
 }
Exemple #26
0
 public AddTime(PlayerFeedback.CountdownTimer ctimer)
 {
     cTimer = ctimer;
 }