public void UpdatePrimaryStat_CallsStatChangedIfDifferent()
        {
            //Arrange
            var newScore      = 12;
            var updateRequest = new PrimaryStatUpdateRequest
            {
                AbilityScore = newScore,
                Id           = API.Dto.AbilityType.Cha
            };

            _primaryStatsService.CachedPrimaryStats = new Dictionary <API.Dto.AbilityType, API.Dto.PrimaryStat>
            {
                { API.Dto.AbilityType.Cha, new API.Dto.PrimaryStat {
                      Id = API.Dto.AbilityType.Cha, AbilityScore = 30
                  } }
            };

            bool called = false;

            _primaryStatsService.PrimaryStatsUpdated += (sender, args) => called = true;

            //Act
            _primaryStatsService.UpdatePrimaryStat(updateRequest);

            //Assert
            called.Should().BeTrue();
        }
Ejemplo n.º 2
0
        public void UpdatePrimaryStat(PrimaryStatUpdateRequest skill)
        {
            if (skill.AbilityScore == CachedPrimaryStats[skill.Id].AbilityScore)
            {
                return;
            }
            CachedPrimaryStats[skill.Id].AbilityScore = skill.AbilityScore;
            AddModifierToPrimaryStat(CachedPrimaryStats[skill.Id]);

            PrimaryStatsUpdated?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 3
0
        public void Update_CallsService()
        {
            //Arrange
            var uiPrimaryStat = new UiPrimaryStat();
            var svcPrimaryStatUpdateRequest = new PrimaryStatUpdateRequest();

            A.CallTo(() => _autoMapper.MapToSvcRequest(uiPrimaryStat)).Returns(svcPrimaryStatUpdateRequest);

            //Act
            _primaryStatModel.Update(uiPrimaryStat);

            //Assert
            A.CallTo(() => _primaryStatsService.UpdatePrimaryStat(svcPrimaryStatUpdateRequest)).MustHaveHappened();
        }
        public void UpdatePrimaryStat_UpdatesRepo()
        {
            //Arrange
            var newScore      = 12;
            var updateRequest = new PrimaryStatUpdateRequest
            {
                AbilityScore = newScore,
                Id           = API.Dto.AbilityType.Cha
            };

            _primaryStatsService.CachedPrimaryStats = new Dictionary <API.Dto.AbilityType, API.Dto.PrimaryStat>
            {
                { API.Dto.AbilityType.Cha, new API.Dto.PrimaryStat {
                      Id = API.Dto.AbilityType.Cha, AbilityScore = 30
                  } }
            };

            //Act
            _primaryStatsService.UpdatePrimaryStat(updateRequest);
            var result = _primaryStatsService.GetAllPrimaryStats();

            //Assert
            result.FirstOrDefault().AbilityScore.Should().Be(newScore);
        }
Ejemplo n.º 5
0
 public void AddPrimaryStat(PrimaryStatUpdateRequest skill)
 {
     throw new NotImplementedException();
 }