mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-28 08:58:37 +00:00
added integration tests
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class BlobClientTests : IDisposable
|
||||
{
|
||||
@@ -33,6 +33,20 @@ public class BlobClientTests : IDisposable
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlobWithRepositoryId()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_context.Repository.Id, blob);
|
||||
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlobWithBase64Contents()
|
||||
{
|
||||
@@ -50,6 +64,23 @@ public class BlobClientTests : IDisposable
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlobWithBase64ContentsAndWithRepositoryId()
|
||||
{
|
||||
var utf8Bytes = Encoding.UTF8.GetBytes("Hello World!");
|
||||
var base64String = Convert.ToBase64String(utf8Bytes);
|
||||
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = base64String,
|
||||
Encoding = EncodingType.Base64
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_context.Repository.Id, blob);
|
||||
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlob()
|
||||
{
|
||||
@@ -70,6 +101,26 @@ public class BlobClientTests : IDisposable
|
||||
Assert.Equal("Hello World!", contents);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlobWithRepositoryId()
|
||||
{
|
||||
var newBlob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_context.Repository.Id, newBlob);
|
||||
var blob = await _fixture.Get(_context.Repository.Id, result.Sha);
|
||||
|
||||
Assert.Equal(result.Sha, blob.Sha);
|
||||
Assert.Equal(EncodingType.Base64, blob.Encoding);
|
||||
|
||||
var contents = Encoding.UTF8.GetString(Convert.FromBase64String(blob.Content));
|
||||
|
||||
Assert.Equal("Hello World!", contents);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlobWithBase64Text()
|
||||
{
|
||||
@@ -94,6 +145,30 @@ public class BlobClientTests : IDisposable
|
||||
Assert.Equal(expectedOutput, blob.Content);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlobWithBase64TextWithRepositoryId()
|
||||
{
|
||||
var utf8Bytes = Encoding.UTF8.GetBytes("Hello World!");
|
||||
var base64String = Convert.ToBase64String(utf8Bytes);
|
||||
|
||||
var newBlob = new NewBlob
|
||||
{
|
||||
Content = base64String,
|
||||
Encoding = EncodingType.Base64
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_context.Repository.Id, newBlob);
|
||||
var blob = await _fixture.Get(_context.Repository.Id, result.Sha);
|
||||
|
||||
Assert.Equal(result.Sha, blob.Sha);
|
||||
Assert.Equal(EncodingType.Base64, blob.Encoding);
|
||||
|
||||
// NOTE: it looks like the blobs you get back from the GitHub API
|
||||
// will have an additional \n on the end. :cool:!
|
||||
var expectedOutput = base64String + "\n";
|
||||
Assert.Equal(expectedOutput, blob.Content);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_context.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user