Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change nuget package icon * Add unit test project * Add one drive public shares support * Add unit tests * Add tests to github actions
- Loading branch information
Showing
14 changed files
with
570 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AnyoneDrive\AnyoneDrive.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace AnyoneDrive.Tests | ||
{ | ||
public class OneDriveFile_Must | ||
{ | ||
|
||
|
||
|
||
[Fact] | ||
public async void Get_Stream() | ||
{ | ||
var httpClient = new HttpClient(); | ||
var root = new OneDriveFolderInfo("https://1drv.ms/f/s!AuveTnis1UC4ylwrkuYqhdobhUGy?e=aq9M7h"); | ||
var folders = await root.GetFoldersAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.NotNull(folders); | ||
|
||
var files = await folders.First().GetFilesAsync(httpClient, CancellationToken.None); | ||
Assert.Equal(5, files.Length); | ||
|
||
using var stream = await files[0].GetStreamAsync(httpClient, CancellationToken.None); | ||
} | ||
|
||
|
||
[Fact] | ||
public async void Read_Stream() | ||
{ | ||
var httpClient = new HttpClient(); | ||
var root = new OneDriveFolderInfo("https://1drv.ms/f/s!AuveTnis1UC4ylwrkuYqhdobhUGy?e=aq9M7h"); | ||
var folders = await root.GetFoldersAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.NotNull(folders); | ||
|
||
var files = await folders.First().GetFilesAsync(httpClient, CancellationToken.None); | ||
|
||
using var stream = await files[0].GetStreamAsync(httpClient, CancellationToken.None); | ||
|
||
byte[] buffer = await stream.ReadBlockAsync(65536); | ||
Assert.Equal(5959, buffer.Length); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
namespace AnyoneDrive.Tests | ||
{ | ||
public class OneDriveFolder_Must | ||
{ | ||
|
||
const string TEST_SHARE = "https://1drv.ms/f/s!AuveTnis1UC4ylwrkuYqhdobhUGy?e=aq9M7h"; | ||
|
||
[Fact] | ||
public async void Get_Two_Items() | ||
{ | ||
|
||
var root = new OneDriveFolderInfo(TEST_SHARE); | ||
var items = await root.GetItemsAsync(new HttpClient(), CancellationToken.None); | ||
|
||
Assert.Equal(2, items.Length); | ||
} | ||
|
||
[Fact] | ||
public async void Get_One_File() | ||
{ | ||
|
||
var root = new OneDriveFolderInfo(TEST_SHARE); | ||
var items = await root.GetFilesAsync(new HttpClient(), CancellationToken.None); | ||
|
||
Assert.Single(items); | ||
} | ||
|
||
|
||
[Fact] | ||
public async void Get_One_Folder() | ||
{ | ||
|
||
var root = new OneDriveFolderInfo(TEST_SHARE); | ||
var items = await root.GetFoldersAsync(new HttpClient(), CancellationToken.None); | ||
|
||
Assert.Single(items); | ||
} | ||
|
||
|
||
[Fact] | ||
public async void Get_SubFolder_Files() | ||
{ | ||
var httpClient = new HttpClient(); | ||
var root = new OneDriveFolderInfo(TEST_SHARE); | ||
var folders = await root.GetFoldersAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.NotNull(folders); | ||
Assert.Single(folders); | ||
Assert.Equal("Single folder", folders[0].Name); | ||
|
||
var files = await folders.First().GetFilesAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.Equal(5, files.Length); | ||
} | ||
|
||
|
||
|
||
[Fact] | ||
public async void Read_File() | ||
{ | ||
var httpClient = new HttpClient(); | ||
var root = new OneDriveFolderInfo(TEST_SHARE); | ||
var folders = await root.GetFoldersAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.NotNull(folders); | ||
|
||
var files = await folders.First().GetFilesAsync(httpClient, CancellationToken.None); | ||
|
||
Assert.Equal(5, files.Length); | ||
|
||
using var stream = await files[0].GetStreamAsync(httpClient, CancellationToken.None); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.