Created
November 3, 2012 12:57
-
-
Save george-silva/4007317 to your computer and use it in GitHub Desktop.
Testes bobos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class ConverterUnitTest | |
{ | |
[SetUp] | |
public void Init() | |
{ | |
var aoInit = new AoInitializeClass(); | |
aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); | |
} | |
[TestCase(CadastralEntity.DISTRICT,"FDIS_DISTRITOS")] | |
[TestCase(CadastralEntity.SECTOR, "FSET_SETORES")] | |
[TestCase(CadastralEntity.BLOCK, "FQDA_QUADRAS")] | |
[TestCase(CadastralEntity.BLOCK_EDGE, "FFQD_FACES_QUADRAS")] | |
[TestCase(CadastralEntity.PARCEL, "FLTE_LOTES")] | |
[TestCase(CadastralEntity.PARCEL_EDGE, "FTES_TESTADAS_LOTES")] | |
[TestCase(CadastralEntity.BUILDING, "FEDF_EDIFICACOES")] | |
[TestCase(CadastralEntity.PAVEMENT, "FPAV_PAVIMENTOS")] | |
[TestCase(CadastralEntity.STREET, "TLOG_LOGRADOUROS")] | |
[TestCase(CadastralEntity.STREET_SEGMENT, "FTRL_TRECHOS_LOGRADOUROS")] | |
public void TestEntityToTable(CadastralEntity e, string datasetLastName) | |
{ | |
var context = ArcMapContext.GetInstance(); | |
var workspace = context.Geodatabase; | |
var table = Converter.EntityToTable(e,workspace); | |
var dataset = (IDataset) table; | |
var lastName = dataset.Name.Split(new char[] {'.'}).Last(); | |
Assert.AreEqual(datasetLastName, lastName); | |
} | |
[TestCase("FDIS_DISTRITOS",CadastralEntity.DISTRICT)] | |
[TestCase("FSET_SETORES",CadastralEntity.SECTOR)] | |
[TestCase("FQDA_QUADRAS",CadastralEntity.BLOCK )] | |
[TestCase("FFQD_FACES_QUADRAS",CadastralEntity.BLOCK_EDGE)] | |
[TestCase("FLTE_LOTES",CadastralEntity.PARCEL)] | |
[TestCase("FTES_TESTADAS_LOTES",CadastralEntity.PARCEL_EDGE)] | |
[TestCase("FEDF_EDIFICACOES",CadastralEntity.BUILDING)] | |
[TestCase("FPAV_PAVIMENTOS",CadastralEntity.PAVEMENT)] | |
[TestCase("TLOG_LOGRADOUROS",CadastralEntity.STREET)] | |
[TestCase("FTRL_TRECHOS_LOGRADOUROS",CadastralEntity.STREET_SEGMENT)] | |
public void TestTableNameToEntity(string tableName, CadastralEntity expectedEntity) | |
{ | |
var entity = Converter.TableNameToEntity(tableName); | |
Assert.AreEqual(expectedEntity, entity); | |
} | |
[Test] | |
[ExpectedException(typeof(ConverterException))] | |
public void TestTableNameToEntityNonExistentTable() | |
{ | |
// http://en.wikipedia.org/wiki/Jakovasaurs | |
var e = Converter.TableNameToEntity("JAKOVASAUR"); | |
} | |
public static ITable EntityToTable(CadastralEntity entity,IWorkspace workspace) | |
{ | |
var featureWorkspace = (IFeatureWorkspace) workspace; | |
switch (entity) | |
{ | |
case CadastralEntity.DISTRICT: | |
return featureWorkspace.OpenTable("FDIS_DISTRITOS"); | |
case CadastralEntity.SECTOR: | |
return featureWorkspace.OpenTable("FSET_SETORES"); | |
case CadastralEntity.BLOCK: | |
return featureWorkspace.OpenTable("FQDA_QUADRAS"); | |
case CadastralEntity.PARCEL: | |
return featureWorkspace.OpenTable("FLTE_LOTES"); | |
case CadastralEntity.BLOCK_EDGE: | |
return featureWorkspace.OpenTable("FFQD_FACES_QUADRAS"); | |
case CadastralEntity.PARCEL_EDGE: | |
return featureWorkspace.OpenTable("FTES_TESTADAS_LOTES"); | |
case CadastralEntity.BUILDING: | |
return featureWorkspace.OpenTable("FEDF_EDIFICACOES"); | |
case CadastralEntity.PAVEMENT: | |
return featureWorkspace.OpenTable("FPAV_PAVIMENTOS"); | |
case CadastralEntity.STREET: | |
return featureWorkspace.OpenTable("TLOG_LOGRADOUROS"); | |
case CadastralEntity.STREET_SEGMENT: | |
return featureWorkspace.OpenTable("FTRL_TRECHOS_LOGRADOUROS"); | |
case CadastralEntity.BLOCK_EDGE_VIEW: | |
return featureWorkspace.OpenTable("VW_AFQD_FACES_QUADRAS"); | |
case CadastralEntity.PARCEL_VIEW: | |
return featureWorkspace.OpenTable("VW_ALTE_LOTES"); | |
case CadastralEntity.BUSINESS_VIEW: | |
return featureWorkspace.OpenTable("VW_TMOB_UNIDADES_MOBILIARIAS"); | |
case CadastralEntity.UNIT_VIEW: | |
return featureWorkspace.OpenTable("VW_TIMO_UNIDADES_IMOBILIARIAS"); | |
case CadastralEntity.HOUSING_VIEW: | |
return featureWorkspace.OpenTable("VW_TUNI_UNIDADES"); | |
case CadastralEntity.STREET_VIEW: | |
return featureWorkspace.OpenTable("VW_TLOG_LOGRADOUROS"); | |
default: | |
throw new ConverterException("Não foi possível determinar a tabela para o tipo de entidade."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment