public static void CharactersAndNumbersAreNotConverted()
        {
            const string expected = "aA1_";
            var          actual   = SmilePBNRecommender.ConvertToLegalSmileName(expected);

            Assert.AreEqual(expected, actual);
        }
        public static void PreceedingNumbersAreHandled()
        {
            var          actual   = SmilePBNRecommender.ConvertToLegalSmileName("1");
            const string expected = "x1";

            Assert.AreEqual(expected, actual);
        }
        public static void NonAlphanumericCharactersAreConvertedToUnderscore()
        {
            const string input    = "aA1!\"§$%&/()=?{[]}-+*#;,:.><|öäüÖÄÜ^€@";
            var          actual   = SmilePBNRecommender.ConvertToLegalSmileName(input);
            const string expected = "aA1___________________________________";

            Assert.AreEqual(expected, actual);
        }
        public void ShouldSetEvidenceOnCallSite()
        {
            var query = Fix.CreateDefaultQuery();

            query.sites.Add(CallSites.CreateReceiverCallSite("LType.Init()LVoid;"));

            _uut.Query(query);

            var actual = _network.GetEvidenceId(SmilePBNRecommender.ConvertToLegalSmileName("C_LType.Init()LVoid;"));

            Assert.AreEqual(Constants.StateTrue, actual);
        }
        private static void AddMethod(Network net, int patternNodeHandle, string methodName, double[] probabilities)
        {
            var nodeId = "C_" + SmilePBNRecommender.ConvertToLegalSmileName(methodName);

            AddNode(
                net,
                patternNodeHandle,
                nodeId,
                methodName,
                new[] { SmilePBNRecommenderConstants.StateTrue, SmilePBNRecommenderConstants.StateFalse },
                Expand(probabilities));
        }
        public void ShouldSetEvidenceOnDefinitionSite()
        {
            var query = Fix.CreateDefaultQuery();

            query.definition = DefinitionSites.CreateDefinitionByReturn("LType.Create()LType;");

            _uut.Query(query);

            var expected = SmilePBNRecommender.ConvertToLegalSmileName("RETURN:LType.Create()LType;");
            var actual   = _network.GetEvidenceId(Constants.DefinitionTitle);

            Assert.AreEqual(expected, actual);
        }
        public void ShouldSetEvidenceOnMethodContext()
        {
            var query = Fix.CreateDefaultQuery();

            query.methodCtx = new CoReMethodName("LType.M()LVoid;");

            _uut.Query(query);

            var expected = SmilePBNRecommender.ConvertToLegalSmileName("LType.M()LVoid;");
            var actual   = _network.GetEvidenceId(Constants.MethodContextTitle);

            Assert.AreEqual(expected, actual);
        }
        private static void SetNodeProperties(this Network net,
                                              int nodeHandle,
                                              IEnumerable <string> states,
                                              double[] probs)
        {
            foreach (var state in states)
            {
                var convertedName = SmilePBNRecommender.ConvertToLegalSmileName(state);
                net.AddOutcome(nodeHandle, convertedName);
            }
            //Remove default states
            net.DeleteOutcome(nodeHandle, "State0");
            net.DeleteOutcome(nodeHandle, "State1");

            net.SetNodeDefinition(nodeHandle, probs);
        }