Skip to content
This repository was archived by the owner on Feb 12, 2019. It is now read-only.

Add 'changes since change id', fix compilation by adding System.Web #81

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/repositories.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<repositories>
<repository path="..\src\Samples\TeamCitySharp.BuildMonitor\packages.config" />
<repository path="..\src\TeamCitySharp\packages.config" />
<repository path="..\src\Tests\IntegrationTests\packages.config" />
<repository path="..\src\Tests\UnitTests\packages.config" />
</repositories>
7 changes: 7 additions & 0 deletions src/TeamCitySharp/ActionTypes/Builds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ internal Builds(TeamCityCaller caller)
_caller = caller;
}

public Build ByBuildInternalId(string buildInternalId)
{
var build = _caller.GetFormat<Build>("/app/rest/builds/id:{0}", buildInternalId);

return build;
}

public List<Build> ByBuildLocator(BuildLocator locator)
{
var buildWrapper = _caller.GetFormat<BuildWrapper>("/app/rest/builds?locator={0}", locator);
Expand Down
13 changes: 10 additions & 3 deletions src/TeamCitySharp/ActionTypes/Changes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using TeamCitySharp.Connection;
using TeamCitySharp.DomainEntities;
Expand Down Expand Up @@ -30,17 +31,23 @@ public Change ByChangeId(string id)

public List<Change> ByBuildConfigId(string buildConfigId)
{
var changeWrapper = _caller.GetFormat<ChangeWrapper>("/app/rest/changes?buildType={0}", buildConfigId);
var changeWrapper = _caller.GetFormat<ChangeWrapper>("/app/rest/changes?buildType=id:{0}", buildConfigId);

return changeWrapper.Change;
}

public List<Change> ByBuildConfigIdSinceChangeId(string buildConfigId, string sinceChangeId)
{
var changeWrapper = _caller.GetFormat<ChangeWrapper>("/app/rest/changes?buildType=id:{0}&sinceChange=id:{1}", buildConfigId, sinceChangeId);

return changeWrapper.Change;
}

public Change LastChangeDetailByBuildConfigId(string buildConfigId)
{
var changes = ByBuildConfigId(buildConfigId);

return changes.FirstOrDefault();
}

}
}
1 change: 1 addition & 0 deletions src/TeamCitySharp/ActionTypes/IBuilds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace TeamCitySharp.ActionTypes
{
public interface IBuilds
{
Build ByBuildInternalId(string buildInternalId);
List<Build> SuccessfulBuildsByBuildConfigId(string buildConfigId);
Build LastSuccessfulBuildByBuildConfigId(string buildConfigId);
List<Build> FailedBuildsByBuildConfigId(string buildConfigId);
Expand Down
1 change: 1 addition & 0 deletions src/TeamCitySharp/ActionTypes/IChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public interface IChanges
Change ByChangeId(string id);
Change LastChangeDetailByBuildConfigId(string buildConfigId);
List<Change> ByBuildConfigId(string buildConfigId);
List<Change> ByBuildConfigIdSinceChangeId(string buildConfigId, string sinceChangeId);
}
}
7 changes: 6 additions & 1 deletion src/TeamCitySharp/DomainEntities/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ public class Build

public BuildConfig BuildConfig { get; set; }
public Agent Agent { get; set;}
public ChangeWrapper Changes { get; set; }

public ChangeWrapper Changes { get; set; }
/// <summary>
/// TeamCity 8.* response to build queries fills changes in LastChanges.
/// </summary>
public ChangeWrapper LastChanges { get; set; }

public override string ToString()
{
Expand Down
1 change: 1 addition & 0 deletions src/TeamCitySharp/TeamCitySharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
13 changes: 13 additions & 0 deletions src/Tests/IntegrationTests/SampleBuildsUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ public void it_returns_all_successful_builds_since_date()
Assert.IsNotNull(builds);
}

[TestCase("bt5")]
public void it_returns_a_build_from_id(string buildConfigId)
{
var builds = _client.Builds.ByBuildConfigId(buildConfigId);

Assert.IsTrue(builds.Any(), "There are no builds from config id " + buildConfigId + ". Cannot test retrieving one!");

var build = _client.Builds.ByBuildInternalId(builds.First().Id);

Assert.IsNotNull(build, "Did not return with a build!");
Assert.IsNotNullOrEmpty(build.Id, "Did not return with a build!");
}

[Test]
public void it_does_not_populate_the_status_text_field_of_the_build_object()
{
Expand Down
8 changes: 8 additions & 0 deletions src/Tests/IntegrationTests/SampleChangeUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@ public void it_returns_change_details_for_build_config(string buildConfigId)

Assert.That(changeDetails != null, "Cannot find details of that specified change");
}

[TestCase("bt113", "42843")]
public void it_returns_change_details_since_build_id(string buildConfigId, string changeId)
{
List<Change> changes = _client.Changes.ByBuildConfigIdSinceChangeId(buildConfigId, changeId);

Assert.That(changes.Any(), "Cannot find any changes since the change id specified");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<Name>TeamCitySharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
3 changes: 3 additions & 0 deletions src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<Name>TeamCitySharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down