/// <summary> /// Deletes the project mapping entry. /// </summary> /// <param name="projectMappingTableName">Name of the project mapping table.</param> /// <param name="projectId">The project id.</param> public void DeleteProjectMappingEntry(string projectMappingTableName, Guid projectId) { Guard.ArgumentNotNullOrEmptyString(projectMappingTableName, "projectMappingTableName"); GuidGuard.GuidNotEmpty(projectId, "projectId"); ProjectMappingTable projectMappingTable = this.ProjectMappingInformation.FindProjectMappingTableByName(projectMappingTableName); if (projectMappingTable == null) { throw new ProjectMappingTableNotFoundException(Properties.Resources.ProjectMappingTableNotFound); } ProjectMapping.Configuration.ProjectMappingEntry projectMapping = projectMappingTable.FindProjectMappingByProjectId(projectId); if (projectMapping == null) { throw new ProjectMappingNotFoundException(Properties.Resources.ProjectNotFound); } //Delete ProjectMapping projectMappingTable.ProjectMappings.Remove(projectMapping); UpdateMappingFile(); }
public void NormalGuidShouldBeInvalidTest() { Guid guid1 = Guid.Empty; Guid guid2 = default; Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid1, nameof(guid1))); Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid2, nameof(guid2))); }
public void NullableGuidShouldBeInvalidTest() { Guid?guid1 = Guid.Empty; Guid?guid2 = null; Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid1, nameof(guid1))); Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid2, nameof(guid2))); }
public ProjectMappingEntry FindProjectMappingByProjectId(Guid projectId) { GuidGuard.GuidNotEmpty(projectId, "projectId"); return(FindProjectMapping(delegate(ProjectMappingEntry projectMapping) { Guid mappingProjectId = new Guid(projectMapping.ProjectId); return mappingProjectId.Equals(projectId); })); }
public void ValidGuidTest() { var guid1 = Guid.Empty; var guid2 = Guid.NewGuid(); Guid?guid3 = guid1; Guid?guid4 = null; Guid?guid5 = guid2; Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid1, "guid1")); GuidGuard.ShouldBeValid(guid2, "guid2"); Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid3, "guid3")); Assert.Throws <ValidationException>(() => GuidGuard.ShouldBeValid(guid4, "guid4")); GuidGuard.ShouldBeValid(guid5, "guid5"); }
/// <summary> /// Gets the project mapping entry. /// </summary> /// <param name="projectMappingTableName">Name of the project mapping table.</param> /// <param name="projectId">The project id.</param> /// <returns></returns> public ProjectMapping.Configuration.ProjectMappingEntry GetProjectMappingEntry( string projectMappingTableName, Guid projectId) { Guard.ArgumentNotNullOrEmptyString(projectMappingTableName, "projectMappingTableName"); GuidGuard.GuidNotEmpty(projectId, "projectId"); ProjectMappingTable projectMappingTable = this.ProjectMappingInformation.FindProjectMappingTableByName(projectMappingTableName); if (projectMappingTable == null) { throw new ProjectMappingTableNotFoundException(Properties.Resources.ProjectMappingTableNotFound); } return(projectMappingTable.FindProjectMappingByProjectId(projectId)); }
/// <summary> /// Gets the project. /// </summary> /// <param name="projectId">The project id.</param> /// <returns></returns> public EnvDTE.Project GetProject(Guid projectId) { GuidGuard.GuidNotEmpty(projectId, "projectId"); return(new HierarchyNode(vsSolution, projectId).ExtObject as EnvDTE.Project); }