public void TestIfArtifactAreEqual() { SearchResult result = new SearchResult(); Artifact artifact = new Artifact(); artifact.ResourceUri = "https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip"; artifact.GroupId = "org.openengsb.framework"; artifact.ArtifactId = "openengsb-framework"; artifact.Version = "2.6.0-SNAPSHOT"; artifact.Packaging = "zip"; artifact.Extension = "zip"; artifact.RepoId = "ossrh-snapshot"; artifact.ContextId = "ossrh-snapshot"; artifact.ArtifactLink = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&g=org.openengsb.framework&a=openengsb-framework&v=2.6.0-SNAPSHOT&e=zip&c=src"; result.Artifacts.Add(artifact); result.Count = 1; result.From = "test"; result.TooManyResults = false; result.TotalCount = 1; Assert.AreEqual<SearchResult>(result, result); }
public void TestSerializerWithTwoArtifactEntries() { SearchResult expectedSearchResult = new SearchResult(); Artifact expectedResult = new Artifact(); expectedResult.ResourceUri = "https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip"; expectedResult.GroupId = "org.openengsb.framework"; expectedResult.ArtifactId = "openengsb-framework"; expectedResult.Version = "2.6.0-SNAPSHOT"; expectedResult.Packaging = "zip"; expectedResult.Extension = "zip"; expectedResult.RepoId = "ossrh-snapshot"; expectedResult.ContextId = "ossrh-snapshot"; expectedResult.ArtifactLink = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&g=org.openengsb.framework&a=openengsb-framework&v=2.6.0-SNAPSHOT&e=zip&c=src"; expectedSearchResult.Artifacts.Add(expectedResult); expectedResult = new Artifact(); expectedResult.ResourceUri = "https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip"; expectedResult.GroupId = "org.openengsb.framework"; expectedResult.ArtifactId = "openengsb-framework"; expectedResult.Version = "2.4.1"; expectedResult.Packaging = "zip"; expectedResult.Extension = "zip"; expectedResult.RepoId = "central-proxy"; expectedResult.ContextId = "Central Proxy"; expectedResult.ArtifactLink = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&g=org.openengsb.framework&a=openengsb-framework&v=2.6.0-SNAPSHOT&e=zip&c=src"; expectedSearchResult.Artifacts.Add(expectedResult); expectedSearchResult.Artifacts.Add(expectedResult); expectedSearchResult.Count = -1; expectedSearchResult.From = "-1"; expectedSearchResult.TooManyResults = false; expectedSearchResult.TotalCount = 28; StringBuilder builder = new StringBuilder(); builder.AppendLine("<search-results>"); builder.AppendLine("<totalCount>28</totalCount>"); builder.AppendLine("<from>-1</from>"); builder.AppendLine("<count>-1</count>"); builder.AppendLine("<tooManyResults>false</tooManyResults>"); builder.AppendLine("<data>"); builder.AppendLine("<artifact>"); builder.AppendLine("<resourceURI>https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip</resourceURI>"); builder.AppendLine("<groupId>org.openengsb.framework</groupId>"); builder.AppendLine("<artifactId>openengsb-framework</artifactId>"); builder.AppendLine("<version>2.6.0-SNAPSHOT</version>"); builder.AppendLine("<classifier>src</classifier>"); builder.AppendLine("<packaging>zip</packaging>"); builder.AppendLine("<extension>zip</extension>"); builder.AppendLine("<repoId>ossrh-snapshot</repoId>"); builder.AppendLine("<contextId>ossrh-snapshot</contextId>"); builder.AppendLine("<pomLink></pomLink>"); builder.AppendLine("<artifactLink>https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&g=org.openengsb.framework&a=openengsb-framework&v=2.6.0-SNAPSHOT&e=zip&c=src</artifactLink>"); builder.AppendLine("</artifact>"); builder.AppendLine("<artifact>"); builder.AppendLine("<resourceURI>https://repository.sonatype.org/service/local/repositories/central-proxy/content/org/openengsb/framework/openengsb-framework/2.4.1/openengsb-framework-2.4.1-src.zip</resourceURI>"); builder.AppendLine("<groupId>org.openengsb.framework</groupId>"); builder.AppendLine("<artifactId>openengsb-framework</artifactId>"); builder.AppendLine("<version>2.4.1</version>"); builder.AppendLine("<classifier>src</classifier>"); builder.AppendLine("<packaging>zip</packaging>"); builder.AppendLine("<extension>zip</extension>"); builder.AppendLine("<repoId>central-proxy</repoId>"); builder.AppendLine("<contextId>Central Proxy</contextId>"); builder.AppendLine("<pomLink></pomLink>"); builder.AppendLine("<artifactLink>https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.openengsb.framework&a=openengsb-framework&v=2.4.1&e=zip&c=src</artifactLink>"); builder.AppendLine("</artifact>"); builder.AppendLine("</data>"); builder.AppendLine("</search-results>"); SonatypeDependencyManager sonaType = new SonatypeDependencyManager(null, null, null, null, null); SearchResult resultArtifact = sonaType.ConvertSearchResult<SearchResult>(builder.ToString()); Assert.AreNotEqual<SearchResult>(expectedSearchResult, resultArtifact); }