Skip to content

Commit

Permalink
feat!: upgrade .net framework to 4.6.2, remove deprecated methods, re…
Browse files Browse the repository at this point in the history
…move `use_index` references, return proper object from `GetFileVersionsUnderRetentionForAssignmentAsync` (#881)

* feat!: upgrade .net framework to 4.6.2 (#863)

* feat!: remove method with `use_index` reference (#870)

* feat!: remove deprecated methods (#874)

* fix!: return proper object type from `GetFileVersionsUnderRetentionForAssignmentAsync` method (#875)

* chore: ignore `bug fixes` in `readme` during linting (#876)
  • Loading branch information
mwwoda authored Jan 12, 2023
1 parent 389c317 commit f1989aa
Show file tree
Hide file tree
Showing 55 changed files with 393 additions and 1,010 deletions.
10 changes: 10 additions & 0 deletions .github/linters/.textlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"filters": {
"comments": true
},
"rules": {
"terminology" : {
"defaultTerms": true
}
}
}
4 changes: 1 addition & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- main
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
framework:
Expand All @@ -30,7 +28,7 @@ jobs:
- name: Build
run: msbuild .\Box.V2
- name: Test
run: dotnet test .\Box.V2.Test -f net45
run: dotnet test .\Box.V2.Test -f net462

core:
name: Build and Test - Core
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- main
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
core:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Lint Code Base
on:
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
build:
Expand All @@ -25,5 +23,6 @@ jobs:
VALIDATE_POWERSHELL: false
VALIDATE_EDITORCONFIG: false
VALIDATE_MARKDOWN: false
NATURAL_LANGUAGE_CONFIG_FILE: .textlintrc
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/spell-check-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: spell-check-lint
on:
pull_request_target:
types: [opened, synchronize, edited]
branches:
- main
jobs:
spellcheck-request-title:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Box.V2.Samples.JWTAuth/Box.V2.Samples.JWTAuth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Box.V2.Samples.JWTAuth</RootNamespace>
<AssemblyName>Box.V2.Samples.JWTAuth</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down
2 changes: 1 addition & 1 deletion Box.V2.Samples.JWTAuth/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
Expand Down
2 changes: 1 addition & 1 deletion Box.V2.Samples.TransactionalAuth/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Box.V2.Samples.TransactionalAuth</RootNamespace>
<AssemblyName>Box.V2.Samples.TransactionalAuth</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
Expand Down
8 changes: 4 additions & 4 deletions Box.V2.Test.Integration/Box.V2.Test.Integration.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks>

<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand All @@ -10,15 +10,15 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('netcoreapp2.0'))">
<ProjectReference Include="..\Box.V2.Core\Box.V2.Core.csproj" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net45'))">
<ItemGroup Condition="$(TargetFramework.StartsWith('net462'))">
<ProjectReference Include="..\Box.V2\Box.V2.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ await Retry(async () =>

[TestMethod]
[ExpectedException(typeof(TimeoutException))]
public async Task DownloadStreamAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload()
public async Task DownloadAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload()
{
var uploadedFile = await CreateSmallFile(FolderId);
var timeout = new TimeSpan(0, 0, 0, 0, 1);

await UserClient.FilesManager.DownloadStreamAsync(uploadedFile.Id, timeout: timeout);
await UserClient.FilesManager.DownloadAsync(uploadedFile.Id, timeout: timeout);
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task SearchAsync_ForNonExistentKeyword_ShouldReturnNoResults()
{
const string Keyword = "NonExistentKeyWord";

BoxCollection<BoxItem> results = await UserClient.SearchManager.SearchAsync(Keyword, 200);
BoxCollection<BoxItem> results = await UserClient.SearchManager.QueryAsync(Keyword, limit: 200);

Assert.IsNotNull(results);
Assert.AreEqual(0, results.Entries.Count);
Expand Down
23 changes: 6 additions & 17 deletions Box.V2.Test/Box.V2.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.2;netcoreapp3.1;net5.0;net6.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.2;netcoreapp3.1;net5.0;net6.0;net462</TargetFrameworks>

<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Moq" Version="4.18.2" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('netcore')) or $(TargetFramework.StartsWith('net5.0')) or $(TargetFramework.StartsWith('net6.0'))">
<ProjectReference Include="..\Box.V2.Core\Box.V2.Core.csproj" />
<PackageReference Include="Moq">
<Version>4.7.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net45'))">
<ItemGroup Condition="$(TargetFramework.StartsWith('net462'))">
<ProjectReference Include="..\Box.V2\Box.V2.csproj" />
<PackageReference Include="Moq">
<Version>4.2.1312.1622</Version>
</PackageReference>
<Reference Include="System" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Box.V2.Test/BoxCCGAuthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public BoxCCGAuthTest()
_boxConfig.SetupGet(x => x.ClientId).Returns("123");
_boxConfig.SetupGet(x => x.ClientSecret).Returns("SECRET");
_boxConfig.SetupGet(x => x.BoxApiHostUri).Returns(new Uri(Constants.BoxApiHostUriString));
_boxConfig.SetupGet(x => x.BoxAuthTokenApiUri).Returns(new Uri(Constants.BoxAuthTokenApiUriString));
_ccgAuth = new BoxCCGAuth(_boxConfig.Object, _service);
}

Expand Down
18 changes: 2 additions & 16 deletions Box.V2.Test/BoxConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void BoxConfig_SetUriString()

var exampleUri = new Uri("https://example.com/");
config = BoxConfigBuilder.CreateFromJsonString(JsonString)
.SetBoxApiUri(exampleUri)
.SetBoxApiHostUri(exampleUri)
.Build();
Assert.AreEqual(config.BoxApiUri, exampleUri);
Assert.AreEqual(config.BoxApiUri, exampleUri + "2.0/");
}

[TestMethod]
Expand Down Expand Up @@ -63,20 +63,6 @@ public void BoxConfig_CreateFromString()
Assert.AreEqual(config.EnterpriseId, "eid-123");
}

[TestMethod]
public void BoxConfig_SetAuthTokenUriString()
{
var boxConfig = new BoxConfigBuilder("", "")
.Build();
Assert.AreEqual(boxConfig.BoxAuthTokenApiUri, new Uri(Constants.BoxAuthTokenApiUriString));

var exampleUri = new Uri("https://example.com/token");
var newConfig = new BoxConfigBuilder("", "")
.SetBoxTokenApiUri(exampleUri)
.Build();
Assert.AreEqual(newConfig.BoxAuthTokenApiUri.ToString(), exampleUri + "/");
}

[TestMethod]
public void BoxConfig_SetBoxApiHostUri()
{
Expand Down
37 changes: 0 additions & 37 deletions Box.V2.Test/BoxFilesManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -865,43 +865,6 @@ public async Task DeleteFile_ErrorResponse_Exception()
}
}

[TestMethod]
public async Task DownloadStream_ValidResponse_ValidStream()
{

using (var exampleFile = new FileStream(string.Format(GetSaveFolderPath(), "example.png"), FileMode.OpenOrCreate))
{
/*** Arrange ***/
var location = new Uri("http://dl.boxcloud.com");
var headers = new HttpResponseMessage().Headers;
headers.Location = location;
Handler.Setup(h => h.ExecuteAsync<BoxFile>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxFile>>(new BoxResponse<BoxFile>()
{
Status = ResponseStatus.Success,
Headers = headers

}));
IBoxRequest boxRequest = null;
Handler.Setup(h => h.ExecuteAsync<Stream>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<Stream>>(new BoxResponse<Stream>()
{
Status = ResponseStatus.Success,
ResponseObject = exampleFile

}))
.Callback<IBoxRequest>(r => boxRequest = r); ;

/*** Act ***/
Stream result = await _filesManager.DownloadStreamAsync("34122832467");

/*** Assert ***/

Assert.IsNotNull(result, "Stream is Null");

}
}

[TestMethod]
public async Task Download_LargeOffset_ValidStream()
{
Expand Down
56 changes: 1 addition & 55 deletions Box.V2.Test/BoxFoldersManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,60 +75,6 @@ public async Task GetFolderItems_ValidResponse_SortDirection()
Assert.AreEqual("DESC", boxRequest.Parameters["direction"]);
}

[TestMethod]
public async Task GetFolder_ValidResponse_ValidFolder()
{
Handler.Setup(h => h.ExecuteAsync<BoxFolder>(It.IsAny<IBoxRequest>()))
.Returns(() => Task.FromResult<IBoxResponse<BoxFolder>>(new BoxResponse<BoxFolder>()
{
Status = ResponseStatus.Success,
ContentString = "{ \"type\":\"folder\", \"id\":\"0\", \"sequence_id\":null, \"etag\":null, \"name\":\"All Files\", \"created_at\":null, \"modified_at\":null, \"description\":\"\", \"size\":61591428468, \"path_collection\":{ \"total_count\":0, \"entries\":[ ] }, \"created_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"modified_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"trashed_at\":null, \"purged_at\":null, \"content_created_at\":null, \"content_modified_at\":null, \"owned_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"shared_link\":null, \"folder_upload_email\":null, \"parent\":null, \"item_status\":\"active\", \"item_collection\":{ \"total_count\":10, \"entries\":[ { \"type\":\"folder\", \"id\":\"766352168\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Books\" }, { \"type\":\"folder\", \"id\":\"869883498\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"bytLabs\" }, { \"type\":\"folder\", \"id\":\"767221958\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Games\" }, { \"type\":\"folder\", \"id\":\"766174084\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Mixes\" }, { \"type\":\"folder\", \"id\":\"57181304\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Muzik\" }, { \"type\":\"folder\", \"id\":\"857305570\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"My\" }, { \"type\":\"folder\", \"id\":\"627316229\", \"sequence_id\":\"1\", \"etag\":\"1\", \"name\":\"My Music Folder\" }, { \"type\":\"folder\", \"id\":\"860155462\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"sample\" }, { \"type\":\"folder\", \"id\":\"775829294\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Software\" }, { \"type\":\"folder\", \"id\":\"811565831\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Test\" } ], \"offset\":0, \"limit\":10, \"order\":[ { \"by\":\"type\", \"direction\":\"ASC\" }, { \"by\":\"name\", \"direction\":\"ASC\" } ] } }"
}));

BoxFolder f = await _foldersManager.GetItemsAsync("0", 10);

Assert.AreEqual(f.Id, "0");
Assert.AreEqual(f.Type, "folder");
Assert.IsNull(f.SequenceId);
Assert.IsNull(f.ETag);
Assert.IsNull(f.CreatedAt);
Assert.IsNull(f.ModifiedAt);
Assert.AreEqual(f.Description, "");
Assert.AreEqual(f.Size, 61591428468);
Assert.AreEqual(f.PathCollection.TotalCount, 0);
Assert.AreEqual(f.PathCollection.Entries.Count, 0);
Assert.AreEqual(f.CreatedBy.Type, "user");
Assert.AreEqual(f.CreatedBy.Id, "189912110");
Assert.AreEqual(f.CreatedBy.Name, "Brian");
Assert.AreEqual(f.CreatedBy.Login, "[email protected]");
Assert.AreEqual(f.ModifiedBy.Type, "user");
Assert.AreEqual(f.ModifiedBy.Id, "189912110");
Assert.AreEqual(f.ModifiedBy.Name, "Brian");
Assert.AreEqual(f.ModifiedBy.Login, "[email protected]");
//Assert.IsNull(f.TrashedAt); // Need to add property
//Assert.IsNull(f.PurgedAt); // Need to add property
//Assert.IsNull(f.ContentCreatedAt); // Need to add property
//Assert.IsNull(f.ContentModifiedAt); // Need to add property
Assert.AreEqual(f.OwnedBy.Type, "user");
Assert.AreEqual(f.OwnedBy.Id, "189912110");
Assert.AreEqual(f.OwnedBy.Name, "Brian");
Assert.AreEqual(f.OwnedBy.Login, "[email protected]");
Assert.IsNull(f.SharedLink);
Assert.IsNull(f.FolderUploadEmail);
Assert.IsNull(f.Parent);
Assert.AreEqual(f.ItemStatus, "active");
Assert.AreEqual(f.Id, "0");
Assert.AreEqual(f.Name, "All Files");
Assert.AreEqual(f.ModifiedBy.Id, "189912110");
Assert.AreEqual(f.ItemCollection.TotalCount, 10);
Assert.AreEqual(f.ItemCollection.Entries.Count, 10);
//Assert.AreEqual(f.Offset, "0"); // Need to add property
//Assert.AreEqual(f.Order[0].By, "type"); // Need to add property
//Assert.AreEqual(f.Order[0].Direction, "ASC"); // Need to add property
//Assert.AreEqual(f.Order[1].By, "name"); // Need to add property
//Assert.AreEqual(f.Order[1].Direction, "ASC"); // Need to add property
}

[TestMethod]
public async Task CreateFolder_ValidResponse_ValidFolder()
{
Expand Down Expand Up @@ -707,7 +653,7 @@ public async Task GetTrashedItems_ValidResponse_ValidFiles()
}));

/*** Act ***/
BoxCollection<BoxItem> i = await _foldersManager.GetTrashItemsAsync("fakeId", 10);
BoxCollection<BoxItem> i = await _foldersManager.GetTrashItemsAsync(10);
BoxItem i1 = i.Entries.FirstOrDefault();
BoxItem i2 = i.Entries.Skip(1).FirstOrDefault();

Expand Down
Loading

0 comments on commit f1989aa

Please sign in to comment.