public void RateConditionMatches_TraitCacheUnfulfilled_ReturnsFalse()
        {
            m_GameObject.AddSemanticTagCondition("tagTrait");
            SetupObject(m_GameObject);

            Assert.False(MatchRatingDataTransform.RateConditionMatches(m_Conditions, m_TraitCache, m_ConditionRatings));
        }
        public void MatchRatingDataTransform_SingleEntry()
        {
            DatabaseTestData.PopulateDatabase(m_Db, 3);
            m_GameObject.AddTestFloatCondition();
            m_GameObject.AddTestVector2Condition(0.9f);
            SetupObject(m_GameObject);

            // TODO - better test for this stage now that it filters indices
            MatchRatingDataTransform.RateConditionMatches(m_Conditions, m_TraitCache, m_ConditionRatings);
            Assert.AreEqual(7, m_ConditionRatings[typeof(float)][0].Count);
            Assert.AreEqual(7, m_ConditionRatings[typeof(Vector2)][0].Count);
        }
        public void RateConditionMatches_NoConditionsMet_ReturnsFalse_WithEmptyRatingSets()
        {
            // all our test trait values are far below 90 / 100, so both should have no matches
            m_GameObject.AddTestFloatCondition(0, 90f);
            m_GameObject.AddTestVector2Condition(100f);
            m_GameObject.AddSemanticTagCondition("traitNotFound");

            SetupObject(m_GameObject);
            Assert.False(MatchRatingDataTransform.RateConditionMatches(m_Conditions, m_TraitCache, m_ConditionRatings));
            Assert.AreEqual(0, m_ConditionRatings[typeof(float)][0].Count);
            Assert.AreEqual(0, m_ConditionRatings[typeof(Vector2)][0].Count);
            Assert.AreEqual(0, m_ConditionRatings[typeof(bool)][0].Count);
        }
        public void RateConditionMatches_SomeConditionsMet_ReturnsFalse()
        {
            m_GameObject.AddTestFloatCondition();
            m_GameObject.AddTestFloatCondition(1, 100f);        // this one will not match
            m_GameObject.AddTestVector2Condition(0.9f);
            SetupObject(m_GameObject);

            Assert.False(MatchRatingDataTransform.RateConditionMatches(m_Conditions, m_TraitCache, m_ConditionRatings));
            Assert.AreEqual(7, m_ConditionRatings[typeof(float)][0].Count);
            Assert.AreEqual(0, m_ConditionRatings[typeof(float)][1].Count);

            // even though this condition would receive some valid ratings based on our data,
            // because a previous condition had 0 matches, we early-out and don't generate ratings for the rest.
            Assert.AreEqual(0, m_ConditionRatings[typeof(Vector2)][0].Count);
        }
        public void RateConditionMatchesGeneric_AllConditionsMetReturnsTrue_WithFilledRatingSets()
        {
            var floatCondition1 = m_GameObject.AddTestFloatCondition();
            var floatCondition2 = m_GameObject.AddTestFloatCondition(1, 0.2f);

            var conditions = new ICondition <float>[] { floatCondition1, floatCondition2 };
            var ratings    = NewRatingsCollection(2);

            var traitValues1 = m_FloatTraits.dictionary[floatCondition1.traitName];
            var traitValues2 = m_FloatTraits.dictionary[floatCondition2.traitName];
            var traitRefs    = new List <Dictionary <int, float> > {
                traitValues1, traitValues2
            };

            Assert.True(MatchRatingDataTransform.RateConditionMatches(conditions, traitRefs, ratings));
            Assert.AreEqual(7, ratings[0].Count);
            Assert.AreEqual(6, ratings[1].Count);
        }
        public void RateConditionMatchesGeneric_NoConditionsMet_ReturnsFalse()
        {
            var floatCondition1 = m_GameObject.AddTestFloatCondition(0, 90f);
            // all our test trait values are far below 100, so this should have no matches
            var floatCondition2 = m_GameObject.AddTestFloatCondition(1, 100f);

            var conditions = new ICondition <float>[] { floatCondition1, floatCondition2 };
            var ratings    = NewRatingsCollection(2);

            var traitValues1 = m_FloatTraits.dictionary[floatCondition1.traitName];
            var traitValues2 = m_FloatTraits.dictionary[floatCondition2.traitName];
            var traitRefs    = new List <Dictionary <int, float> > {
                traitValues1, traitValues2
            };

            Assert.False(MatchRatingDataTransform.RateConditionMatches(conditions, traitRefs, ratings));
            Assert.AreEqual(0, ratings[0].Count);
            Assert.AreEqual(0, ratings[1].Count);
        }
        public void RateConditionMatches_AllConditionsMet_ReturnsTrueWithAllProposals()
        {
            m_GameObject.AddTestFloatCondition();
            m_GameObject.AddTestVector2Condition(0.9f);
            var matchingTagCondition = m_GameObject.AddSemanticTagCondition("tagTrait");

            m_Db.GetTraitProvider(out MARSTraitDataProvider <bool> semanticTagProvider);
            foreach (var kvp in DatabaseTestData.FloatTraits)
            {
                semanticTagProvider.AddOrUpdateTrait(kvp.Key, matchingTagCondition.traitName, true);
            }

            SetupObject(m_GameObject);

            Assert.True(MatchRatingDataTransform.RateConditionMatches(m_Conditions, m_TraitCache, m_ConditionRatings));
            Assert.AreEqual(7, m_ConditionRatings[typeof(float)][0].Count);
            Assert.AreEqual(7, m_ConditionRatings[typeof(Vector2)][0].Count);
            Assert.AreEqual(10, m_ConditionRatings[typeof(bool)][0].Count);
        }