Example #1
0
 static bool IsAttributeValueResolved(
     string attributeValue,
     MultilinerBotConfiguration.StatusProperty statusAttribute)
 {
     return(attributeValue.Equals(statusAttribute.ResolvedValue,
                                  StringComparison.InvariantCultureIgnoreCase));
 }
Example #2
0
 static bool IsRelevantAttribute(
     string attributeName,
     MultilinerBotConfiguration.StatusProperty statusAttribute)
 {
     return(attributeName.Equals(statusAttribute.Name,
                                 StringComparison.InvariantCultureIgnoreCase));
 }
Example #3
0
        public void TestNoAttrYesCodeReviewFilterDefinedSucceeds()
        {
            bool bIsCodeReviewFilterEnabled = true;

            string attrName          = "status";
            string resolvedAttrValue = string.Empty;
            string testingAttrValue  = string.Empty;
            string failedAttrValue   = string.Empty;
            string mergedAttrValue   = "merged";

            string errorMsg;

            MultilinerBotConfiguration.StatusProperty statusConf =
                new MultilinerBotConfiguration.StatusProperty(
                    attrName, resolvedAttrValue, testingAttrValue, failedAttrValue, mergedAttrValue);

            MultilinerBotConfiguration.PlasticSCM plasticConfig = new MultilinerBotConfiguration.PlasticSCM(
                bIsCodeReviewFilterEnabled,
                statusConf);

            Assert.IsTrue(plasticConfig.IsApprovedCodeReviewFilterEnabled);
            Assert.IsFalse(plasticConfig.IsBranchAttrFilterEnabled);

            bool bResult = MultilinerBotConfigurationChecker.CheckValidPlasticFields(plasticConfig, out errorMsg);

            Assert.IsTrue(bResult, "CheckValidPlasticFields should have succeed!");

            Assert.AreEqual(string.Empty, errorMsg);
        }
Example #4
0
        public void TestNoValidAttrYesCodeReviewFilterDefinedFails()
        {
            bool bIsCodeReviewFilterEnabled = true;

            string attrName          = string.Empty;
            string resolvedAttrValue = string.Empty;
            string testingAttrValue  = string.Empty;
            string failedAttrValue   = string.Empty;
            string mergedAttrValue   = string.Empty;

            string errorMsg;

            MultilinerBotConfiguration.StatusProperty statusConf =
                new MultilinerBotConfiguration.StatusProperty(
                    attrName, resolvedAttrValue, testingAttrValue, failedAttrValue, mergedAttrValue);

            MultilinerBotConfiguration.PlasticSCM plasticConfig = new MultilinerBotConfiguration.PlasticSCM(
                bIsCodeReviewFilterEnabled,
                statusConf);

            Assert.IsTrue(plasticConfig.IsApprovedCodeReviewFilterEnabled);
            Assert.IsFalse(plasticConfig.IsBranchAttrFilterEnabled);

            bool bResult = MultilinerBotConfigurationChecker.CheckValidPlasticFields(plasticConfig, out errorMsg);

            Assert.IsFalse(
                bResult,
                "CheckValidPlasticFields should have failed " +
                "due to no valid basic attr name and merged value defined when only code review filter enabled");

            Assert.AreEqual(Normalize(BuildInvalidAttributeDefinedMessage()), Normalize(errorMsg));
        }
Example #5
0
        public void TestNoValidMergedAttrYesCodeReviewFilterDefinedFails()
        {
            bool bIsCodeReviewFilterEnabled = true;

            string attrName          = "status";
            string resolvedAttrValue = "resolved";
            string testingAttrValue  = "testing";
            string failedAttrValue   = "failed";
            string mergedAttrValue   = string.Empty;

            string errorMsg;

            MultilinerBotConfiguration.StatusProperty statusConf =
                new MultilinerBotConfiguration.StatusProperty(
                    attrName, resolvedAttrValue, testingAttrValue, failedAttrValue, mergedAttrValue);

            MultilinerBotConfiguration.PlasticSCM plasticConfig = new MultilinerBotConfiguration.PlasticSCM(
                bIsCodeReviewFilterEnabled,
                statusConf);

            bool bResult = MultilinerBotConfigurationChecker.CheckValidPlasticFields(plasticConfig, out errorMsg);

            Assert.IsTrue(plasticConfig.IsApprovedCodeReviewFilterEnabled);
            Assert.IsTrue(plasticConfig.IsBranchAttrFilterEnabled);

            Assert.IsFalse(
                bResult,
                "CheckValidPlasticFields should have failed due to no " +
                "resolved value set when only attr filter is defined");

            Assert.AreEqual(
                Normalize("* The merged value of the status attribute for Plastic config must be defined."),
                Normalize(errorMsg));
        }
Example #6
0
        public void TestNoAttrNoCodeReviewFiltersDefinedFails()
        {
            bool bIsCodeReviewFilterEnabled = false;

            string attrName          = string.Empty;
            string resolvedAttrValue = string.Empty;
            string testingAttrValue  = string.Empty;
            string failedAttrValue   = string.Empty;
            string mergedAttrValue   = string.Empty;

            string errorMsg;

            MultilinerBotConfiguration.StatusProperty statusConf =
                new MultilinerBotConfiguration.StatusProperty(
                    attrName, resolvedAttrValue, testingAttrValue, failedAttrValue, mergedAttrValue);

            MultilinerBotConfiguration.PlasticSCM plasticConfig = new MultilinerBotConfiguration.PlasticSCM(
                bIsCodeReviewFilterEnabled,
                statusConf);

            Assert.IsFalse(plasticConfig.IsApprovedCodeReviewFilterEnabled);
            Assert.IsFalse(plasticConfig.IsBranchAttrFilterEnabled);

            bool bResult = MultilinerBotConfigurationChecker.CheckValidPlasticFields(plasticConfig, out errorMsg);

            Assert.IsFalse(bResult, "CheckValidPlasticFields should have failed due to no filters defined");

            Assert.AreEqual(Normalize(BuildNoFiltersEnabledErrorMessage()), Normalize(errorMsg));
        }