public async Task EnsuresNonNullAndNonEmptyArguments() { var connection = Substitute.For <IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List <string> { "fake/repo" }); await Assert.ThrowsAsync <ArgumentNullException>( () => client.Start(null, migrationRequest)); await Assert.ThrowsAsync <ArgumentException>( () => client.Start("", migrationRequest)); await Assert.ThrowsAsync <ArgumentNullException>( () => client.Start("fake", null)); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List<string> { "fake/repo" }); client.Start("fake", migrationRequest); connection.Received().Post<Migration>( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations"), Arg.Any<StartMigrationRequest>(), AcceptHeaders.MigrationsApiPreview); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List <string> { "fake/repo" }); client.Start("fake", migrationRequest); connection.Received().Post <Migration>( Arg.Is <Uri>(u => u.ToString() == "orgs/fake/migrations"), Arg.Any <StartMigrationRequest>(), "application/vnd.github.wyandotte-preview+json"); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List <string> { "fake/repo" }); client.Start("fake", migrationRequest); connection.Received().Post <Migration>( Arg.Is <Uri>(u => u.ToString() == "orgs/fake/migrations"), Arg.Any <StartMigrationRequest>(), AcceptHeaders.MigrationsApiPreview); }
public void PassesRequestBody() { var connection = Substitute.For <IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List <string> { "fake/repo" }); client.Start("fake", migrationRequest); connection.Received().Post <Migration>( Arg.Any <Uri>(), Arg.Is <StartMigrationRequest>(m => m.Repositories.Equals(migrationRequest.Repositories) && m.LockRepositories == migrationRequest.LockRepositories && m.ExcludeAttachments == migrationRequest.ExcludeAttachments), "application/vnd.github.wyandotte-preview+json"); }
public async Task EnsuresNonNullAndNonEmptyArguments() { var connection = Substitute.For<IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List<string> { "fake/repo" }); await Assert.ThrowsAsync<ArgumentNullException>( () => client.Start(null, migrationRequest)); await Assert.ThrowsAsync<ArgumentException>( () => client.Start("", migrationRequest)); await Assert.ThrowsAsync<ArgumentNullException>( () => client.Start("fake", null)); }
public void PassesRequestBody() { var connection = Substitute.For<IApiConnection>(); var client = new MigrationsClient(connection); var migrationRequest = new StartMigrationRequest(new List<string> { "fake/repo" }); client.Start("fake", migrationRequest); connection.Received().Post<Migration>( Arg.Any<Uri>(), Arg.Is<StartMigrationRequest>(m => m.Repositories.Equals(migrationRequest.Repositories) && m.LockRepositories == migrationRequest.LockRepositories && m.ExcludeAttachments == migrationRequest.ExcludeAttachments), AcceptHeaders.MigrationsApiPreview); }