public void TestValidateNotExist(int countIndex, bool expectedIsValid) { // Arrange: fshMock.Setup(f => f.GetFolders(RootPath, FolderPattern)).Returns(Counts[countIndex]); // Act: var rule = new FolderRule(FolderPattern, CheckType.MustNotExist, fshMock.Object); var validationResult = rule.Validate(repositoryInfo); // Assert: fshMock.Verify(f => f.GetFolders(RootPath, FolderPattern), Times.Once); Assert.AreEqual(expectedIsValid, validationResult.IsValid); }
private void buttonCancel_Click(object sender, EventArgs e) { if (refreshing) { return; } if (OpenMode) { return; } myRule = null; Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { using (FolderRule rule = new FolderRule()) { try { grvFolder.DataSource = rule.ConsultarFolder(); grvFolder.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } } } }
/// <summary> /// Find the best-match rule that corresponds to a given importer. /// </summary> /// <returns>The best matching rule (or null)</returns> /// <param name="assetImporter">The AssetImporter (comes from an asset)</param> /// <param name="folderRules">The list of rules to choose from</param> public static T FindBestRule <T>(AssetImporter assetImporter, IEnumerable <T> folderRules) where T : FolderRule { string assetPath = System.IO.Path.GetFullPath(assetImporter.assetPath); // Find best matching texture folder rule. Best match is the longest matching full path FolderRule bestMatch = null; foreach (var rule in folderRules) { // Is this rule a parent of the path? string folderPath = System.IO.Path.GetFullPath(rule.folderPath); if (assetPath.StartsWith(folderPath)) { // Best match is the match with the longest path (i.e. this is the closest folder) if ((bestMatch == null) || rule.folderPath.Length > bestMatch.folderPath.Length) { bestMatch = rule; } } } return((T)bestMatch); }
public PropertiesFolderRuleSearchDialog(int folderID, string folderName, Rule rule) { refreshing = false; state = new XmlDocument(); state.AppendChild(state.CreateElement("myRule")); myRule = new FolderRule(rule.ID); if (myRule.IsNew) { changeMode = false; myRule.Folder = new Folder(folderID); Text = Environment.StringResources.GetString("Properties.PropertiesFolderRuleSearchDialog.Message1") + " \"" + myRule.Folder.Name + "\""; } else { changeMode = true; Text = Environment.StringResources.GetString("Properties.PropertiesFolderRuleSearchDialog.Message2") + " \"" + myRule.Folder.Name + "\""; } OpenMode = true; InitializeComponent(); }