private async Task <ProjectInfo> AddTwoProjectsWithSameRepoStamp(RepositoryManagementService service) { ManifestQueryResult allProjects; //add two projects with same repo stamp RepoCat.Transmission.Models.ProjectInfo prj = new RepoCat.Transmission.Models.ProjectInfo() { ProjectName = "Project1", ProjectUri = "SomeLocation", RepositoryInfo = new RepoCat.Transmission.Models.RepositoryInfo() { RepositoryName = this.testRepoOne.RepositoryName, OrganizationName = this.testRepoOne.OrganizationName, }, TargetExtension = "exe", RepositoryStamp = "1.0" }; await service.Upsert(prj).ConfigureAwait(false); RepoCat.Transmission.Models.ProjectInfo prj2 = new RepoCat.Transmission.Models.ProjectInfo() { ProjectName = "Project2", ProjectUri = "SomeLocation", DocumentationUri = "http://google.com/Somewhere", RepositoryInfo = new RepoCat.Transmission.Models.RepositoryInfo() { RepositoryName = this.testRepoOne.RepositoryName, OrganizationName = this.testRepoOne.OrganizationName, }, TargetExtension = "exe", RepositoryStamp = "1.0", AssemblyName = "Project2AssName", Components = { new ComponentManifest(new List <string>() { "One", "Two" }, new PropertiesCollection() { ("KeyOne", "ValueOne") } ) } }; ProjectInfo returnedPrj2 = await service.Upsert(prj2).ConfigureAwait(false); allProjects = await service.GetAllCurrentProjects(this.testRepoOne).ConfigureAwait(false); allProjects.Projects.Count.Should().Be(2, "because we just added 2 projects with same stamp"); allProjects.Projects.Should().OnlyContain(x => x.ProjectInfo.RepositoryStamp == "1.0"); return(returnedPrj2); }
public async Task SnapshotRepo_ShouldOnlyReturnLastProjects() { RepositoryDatabase database = new RepositoryDatabase(Settings); var service = new RepositoryManagementService(database, new Mapper(MappingConfigurationFactory.Create()), this.telemetryClient); await SetSnapshotMode(database, this.testRepoOne).ConfigureAwait(false); var allProjects = await service.GetAllCurrentProjects(this.testRepoOne).ConfigureAwait(false); allProjects.Projects.Count.Should().Be(0, "because there are no projects yet"); ProjectInfo returnedPrj2 = await this.AddTwoProjectsWithSameRepoStamp(service).ConfigureAwait(false); //now add just one with new stamp RepoCat.Transmission.Models.ProjectInfo prj2Again = new RepoCat.Transmission.Models.ProjectInfo() { ProjectName = "Project2", ProjectUri = "SomeLocation", RepositoryInfo = new RepoCat.Transmission.Models.RepositoryInfo() { RepositoryName = this.testRepoOne.RepositoryName, OrganizationName = this.testRepoOne.OrganizationName, }, TargetExtension = "exe", RepositoryStamp = "2.0" }; var returnedPrj2Again = await service.Upsert(prj2Again).ConfigureAwait(false); allProjects = await service.GetAllCurrentProjects(this.testRepoOne).ConfigureAwait(false); allProjects.Projects.Count.Should().Be(1, "because recently only added 1 project"); allProjects.Projects.Should().OnlyContain(x => x.ProjectInfo.RepositoryStamp == "2.0"); returnedPrj2Again.Id.Should().NotBe(returnedPrj2.Id); returnedPrj2Again.ProjectUri.Should().Be(returnedPrj2.ProjectUri); returnedPrj2Again.ProjectName.Should().Be(returnedPrj2.ProjectName); returnedPrj2Again.RepositoryId.Should().Be(returnedPrj2.RepositoryId); }
public async Task DefaultRepo_ShouldReturnUpdatedProjects() { RepositoryDatabase database = new RepositoryDatabase(Settings); var service = new RepositoryManagementService(database, new Mapper(MappingConfigurationFactory.Create()), this.telemetryClient); var allProjects = await service.GetAllCurrentProjects(this.testRepoOne).ConfigureAwait(false); allProjects.Projects.Count.Should().Be(0, "because there are no projects yet"); await this.AddTwoProjectsWithSameRepoStamp(service).ConfigureAwait(false); ProjectInfo returnedPrj2 = await this.AddTwoProjectsWithSameRepoStamp(service).ConfigureAwait(false); //now add just one with new stamp and some changed properties (except for name and URI) RepoCat.Transmission.Models.ProjectInfo prj2Again = new RepoCat.Transmission.Models.ProjectInfo() { ProjectName = "Project2", ProjectUri = "SomeLocation", Owner = "An Owner", ProjectDescription = "A description", RepositoryInfo = new RepoCat.Transmission.Models.RepositoryInfo() { RepositoryName = this.testRepoOne.RepositoryName, OrganizationName = this.testRepoOne.OrganizationName, }, TargetExtension = "exe", RepositoryStamp = "2.0", AssemblyName = "Project2AssName_NEW", Components = { new ComponentManifest(new List <string>() { "Three", "Four" }, new PropertiesCollection() { { "KeyTwo", "ValueTwo" } } ) } }; var returnedPrj2Again = await service.Upsert(prj2Again).ConfigureAwait(false); allProjects = await service.GetAllCurrentProjects(this.testRepoOne).ConfigureAwait(false); allProjects.Projects.Count.Should().Be(2, "because we don't return latest stamp only"); allProjects.Projects.Should().Contain(x => x.ProjectInfo.RepositoryStamp == "2.0"); allProjects.Projects.Should().Contain(x => x.ProjectInfo.RepositoryStamp == "1.0"); returnedPrj2Again.Id.Should().Be(returnedPrj2.Id); returnedPrj2Again.ProjectUri.Should().Be(returnedPrj2.ProjectUri); returnedPrj2Again.ProjectName.Should().Be(returnedPrj2.ProjectName); returnedPrj2Again.RepositoryId.Should().Be(returnedPrj2.RepositoryId); var prj2ReturnedFromQuery = allProjects.Projects.Single(x => string.Equals(x.ProjectInfo.ProjectName, "Project2", StringComparison.Ordinal)); prj2ReturnedFromQuery.ProjectInfo.Id.Should().Be(returnedPrj2Again.Id); prj2ReturnedFromQuery.ProjectInfo.RepositoryStamp.Should().Be("2.0"); prj2ReturnedFromQuery.ProjectInfo.AssemblyName.Should().Be("Project2AssName_NEW"); prj2ReturnedFromQuery.ProjectInfo.Components.Single().Tags.Count.Should().Be(2); prj2ReturnedFromQuery.ProjectInfo.Components.Single().Properties.Count.Should().Be(1); prj2ReturnedFromQuery.ProjectInfo.Components.Single().Properties["KeyTwo"].Should().Be("ValueTwo"); prj2ReturnedFromQuery.ProjectInfo.Owner.Should().Be("An Owner"); prj2ReturnedFromQuery.ProjectInfo.ProjectDescription.Should().Be("A description"); }