public void GetReleaseId_NoBuilds_ReturnsNull() { IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>(); IAuthenticator authenticator = Substitute.For <IAuthenticator>(); VstsConfig vstsConfig = new VstsConfig(); authenticator.Authenticate().Returns(new AuthenticationResult { Success = true }); releaseClient.GetReleaseDefinitions(Arg.Any <string>(), Arg.Any <string>()).Returns(GetTestReleaseDefinitions()); this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig); string result = this.sut.GetReleaseId("someService", version: "someVersion"); Assert.Null(result); }
public void GetReleaseId_WithPrereqEnv_GetsReleaseWithPrereq() { IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>(); IAuthenticator authenticator = Substitute.For <IAuthenticator>(); VstsConfig vstsConfig = new VstsConfig(); authenticator.Authenticate().Returns(new AuthenticationResult { Success = true }); releaseClient.GetReleaseDefinitions(Arg.Any <string>(), Arg.Any <string>()).Returns(GetTestReleaseDefinitions()); this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig); this.sut.GetReleaseId("someService", version: null, prereqEnvironment: "someEnvironment"); releaseClient.Received().GetReleases(Arg.Any <int>(), Arg.Any <string>(), null, Arg.Any <int>()); }
public void GetReleaseId_WithBranch_GetsBuilds() { IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>(); IAuthenticator authenticator = Substitute.For <IAuthenticator>(); VstsConfig vstsConfig = new VstsConfig(); authenticator.Authenticate().Returns(new AuthenticationResult { Success = true }); releaseClient.GetReleaseDefinitions(Arg.Any <string>(), Arg.Any <string>()).Returns(GetTestReleaseDefinitions()); this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig); this.sut.GetReleaseId("someService", branch: "someBranch"); releaseClient.ReceivedWithAnyArgs().GetBuilds(default(int), default(string), default(string), default(string)); }