Skip to content

Commit

Permalink
box#746 - Exclude Unit Tests from Code Coverage Calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-Oleson committed Sep 9, 2021
1 parent abd4c12 commit ae4c533
Show file tree
Hide file tree
Showing 50 changed files with 159 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ $RECYCLE.BIN/
.DS_Store
*.nupkg
/.vs

# Jetbrains files
.idea*
6 changes: 2 additions & 4 deletions Box.V2.Test.Integration/BoxAuthTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Box.V2.Models;
using System.Threading.Tasks;
using Box.V2.Auth;
using System.Diagnostics;
using Box.V2.Config;
using Box.V2.JWTAuth;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxAuthTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
using Box.V2.Models;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Box.V2.Config;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxCollaborationWhitelistManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -75,7 +77,7 @@ public async Task DomainWhitelist_LiveSession_ValidResponse()
Assert.AreEqual(retrievedWhiteList.Id, whiteList.Id);
Assert.AreEqual("collaboration_whitelist_entry", retrievedWhiteList.Type);

Assert.IsTrue(deletedWhiteList, "Collab whitelist was unable to be deleted");
Assert.IsTrue(deletedWhiteList, "Collab whitelist was unable to be deleted");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using Box.V2.Models;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxCollaborationsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -59,7 +61,7 @@ public async Task CollaborationsOnFolderWorkflow_LiveSession_ValidResponse()
Assert.IsTrue(success, "Collaboration deletion was unsucessful");
}

// Test to add collaboration by Box User ID and Box Group ID.
// Test to add collaboration by Box User ID and Box Group ID.
[TestMethod]
public async Task AddGroupCollaboration_File_Fields_ValidResponse()
{
Expand Down Expand Up @@ -127,7 +129,7 @@ public async Task CollaborationsOnFileWorkflow_LiveSession_ValidResponse()
Assert.AreEqual(fileId, collab.Item.Id, "File and collaboration file id do not match");
Assert.AreEqual(BoxCollaborationRoles.Viewer, collab.Role, "Incorrect collaboration role");


// TODO: Edit Collaboration
BoxCollaborationRequest editRequest = new BoxCollaborationRequest()
{
Expand All @@ -146,7 +148,7 @@ public async Task CollaborationsOnFileWorkflow_LiveSession_ValidResponse()

// test getting list of collaborations on file
var collabs = await _client.FilesManager.GetCollaborationsAsync(fileId);
Assert.AreEqual(4, collabs.Entries.Count, "Failed to get correct number of file collabs.");
Assert.AreEqual(4, collabs.Entries.Count, "Failed to get correct number of file collabs.");

// Test Remove Collaboration
bool success = await _client.CollaborationsManager.RemoveCollaborationAsync(collab.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxCollectionsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
7 changes: 4 additions & 3 deletions Box.V2.Test.Integration/BoxCommentsManagerTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Box.V2.Models;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxCommentsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand All @@ -24,7 +25,7 @@ public async Task CommentsWorkflow_LiveSession_ValidResponse()
Type = BoxType.file
}
};

BoxComment c = await _client.CommentsManager.AddCommentAsync(addReq);

Assert.AreEqual(fileId, c.Item.Id, "Comment was added to incorrect file");
Expand Down Expand Up @@ -57,7 +58,7 @@ public async Task CommentsWorkflow_LiveSession_ValidResponse()

Assert.AreEqual(c.Id, cInfo.Id, "two comment objects have different ids");
Assert.AreEqual(BoxType.comment.ToString(), cInfo.Type, "returned object is not a comment");

// Update the comment
const string updateMessage = "this is an updated test comment";

Expand Down
2 changes: 2 additions & 0 deletions Box.V2.Test.Integration/BoxConfigTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using Box.V2.Config;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxConfigTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
2 changes: 2 additions & 0 deletions Box.V2.Test.Integration/BoxDevicePinManagerTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxDevicePinManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
8 changes: 5 additions & 3 deletions Box.V2.Test.Integration/BoxEventsManagerTestIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxEventsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -97,7 +99,7 @@ await _client.EventsManager.LongPollUserEvents(events.NextStreamPosition,

Thread.Sleep(1000);

//make some events
//make some events
var fileLock = await _client.FilesManager.LockAsync(new BoxFileLockRequest() { Lock = new BoxFileLock() { IsDownloadPrevented = false } }, fileId);
var result = await _client.FilesManager.UnLock(fileId);

Expand All @@ -107,7 +109,7 @@ await _client.EventsManager.LongPollUserEvents(events.NextStreamPosition,
}
catch (AggregateException e)
{
//Console.WriteLine("\nAggregateException thrown with the following inner exceptions:");
//Console.WriteLine("\nAggregateException thrown with the following inner exceptions:");
foreach (var v in e.InnerExceptions)
{
if (v is TaskCanceledException)
Expand All @@ -120,7 +122,7 @@ await _client.EventsManager.LongPollUserEvents(events.NextStreamPosition,
{
//Console.WriteLine(" Exception: {0}", v.GetType().Name);
Assert.Fail("Failed to get events using long polling.");
}
}
}
}
finally
Expand Down
8 changes: 5 additions & 3 deletions Box.V2.Test.Integration/BoxFilesManagerTestIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Box.V2.Models;
using Box.V2.Utility;
Expand All @@ -12,7 +13,8 @@
using System.Reflection;

namespace Box.V2.Test.Integration
{
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxFilesManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -471,7 +473,7 @@ await _client.FilesManager.UploadUsingSessionAsync(fileInMemoryStream, remoteFil
string fileId = await GetFileId(parentFolderId, remoteFileName);

// Using previously uploaded Box file, upload a new file version for that Box file
var newBoxFile = await _client.FilesManager.UploadNewVersionUsingSessionAsync(fileInMemoryStream, fileId, newRemoteFileName,
var newBoxFile = await _client.FilesManager.UploadNewVersionUsingSessionAsync(fileInMemoryStream, fileId, newRemoteFileName,
null, progress);

Assert.IsNotNull(newBoxFile.FileVersion, "Did not successfully upload a new Box file version");
Expand Down Expand Up @@ -522,7 +524,7 @@ public async Task GetRepresentationContentAsync_E2E()
byte[] assetBytes = memStream.ToArray();

Assert.IsTrue(assetBytes.Length > 4096, "Downlaoded asset contained " + assetBytes.Length + " but should contain more than 4 KB");
}
}
}

#region Private functions
Expand Down
8 changes: 5 additions & 3 deletions Box.V2.Test.Integration/BoxFoldersManagerTestIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
using System.Collections.Generic;
using System.Linq;
using System;
using System.Diagnostics.CodeAnalysis;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxFoldersManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -55,9 +57,9 @@ private static async Task AssertFolderContents(BoxClient boxClient)
const int numFiles = 9;
const int numFolders = 2;

BoxCollection<BoxItem> c = await boxClient.FoldersManager.GetFolderItemsAsync("0", 3, 0, new List<string>() {
BoxItem.FieldName,
BoxItem.FieldSize,
BoxCollection<BoxItem> c = await boxClient.FoldersManager.GetFolderItemsAsync("0", 3, 0, new List<string>() {
BoxItem.FieldName,
BoxItem.FieldSize,
BoxFolder.FieldItemCollection
}, autoPaginate: true);

Expand Down
10 changes: 6 additions & 4 deletions Box.V2.Test.Integration/BoxGroupsManagerTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Box.V2.Models;
Expand All @@ -7,6 +8,7 @@

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxGroupsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand All @@ -17,7 +19,7 @@ public async Task GroupsWorkflow_ValidRequest_GetGroups()
var allGroupsInit = await _client.GroupsManager.GetAllGroupsAsync();
var oneGroup = await _client.GroupsManager.GetGroupAsync(allGroupsInit.Entries[0].Id);
Assert.AreEqual(allGroupsInit.Entries[0].Name, oneGroup.Name, "Did not retrieve the correct group");

// Create a new group
string groupName = GetUniqueName();

Expand Down Expand Up @@ -55,7 +57,7 @@ public async Task GroupsWorkflow_ValidRequest_GetGroups()
var delResult = await _client.GroupsManager.DeleteAsync(newGroup.Id);
var allGroupsAfterDelete = await _client.GroupsManager.GetAllGroupsAsync();

Assert.IsTrue(delResult, "Group was not deleted successfully");
Assert.IsTrue(delResult, "Group was not deleted successfully");
Assert.AreEqual(allGroupsInit.TotalCount, allGroupsAfterDelete.TotalCount, "Number of groups after delete is not correct");
Assert.IsFalse(allGroupsAfterDelete.Entries.Any(x => x.Id == newGroup.Id), "Deleted group still exists");
}
Expand Down Expand Up @@ -104,7 +106,7 @@ public async Task GroupMembershipWorkflow_ValidRequest()
request = new BoxGroupMembershipRequest() { Role = "admin" };
var updatedMembership = await _client.GroupsManager.UpdateGroupMembershipAsync(responseMembership.Id, request);
Assert.AreEqual("admin", updatedMembership.Role, "Membership role was not updated correctly");

// Get all memberships for the given groups
var memberships = await _client.GroupsManager.GetAllGroupMembershipsForGroupAsync(newGroup.Id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Box.V2.Models;
Expand All @@ -7,6 +8,7 @@

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxLegalHoldPoliciesManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand All @@ -25,7 +27,7 @@ public async Task LegalHoldPoliciesWorkflow_ValidRequest()
PolicyName = policyName,
Description = description,
FilterStartedAt = filterStarted,
FilterEndedAt = filterEnded
FilterEndedAt = filterEnded
});

Assert.IsNotNull(legalHold.Id);
Expand Down
4 changes: 3 additions & 1 deletion Box.V2.Test.Integration/BoxMetadataManagerTestIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxMetadataManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down Expand Up @@ -72,7 +74,7 @@ public async Task Metadata_DeleteTemplate_LiveSession()
await _client.MetadataManager.GetMetadataTemplate(scope, templateKey);
} catch (BoxException e)
{
Assert.IsNotNull(e);
Assert.IsNotNull(e);
}
Assert.IsTrue(templateIsDeleted, "Failed to delete metadata template");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Box.V2.Models;
using System.Diagnostics.CodeAnalysis;
using Box.V2.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxRecentItemsManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
2 changes: 2 additions & 0 deletions Box.V2.Test.Integration/BoxResourceManagerTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Box.V2.Auth;
using Box.V2.Request;
using Box.V2.Config;
Expand All @@ -11,6 +12,7 @@

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public abstract class BoxResourceManagerTestIntegration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using Box.V2.Models.Request;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;

namespace Box.V2.Test.Integration
{
[ExcludeFromCodeCoverage]
[TestClass]
public class BoxRetentionPoliciesManagerTestIntegration : BoxResourceManagerTestIntegration
{
Expand Down
Loading

0 comments on commit ae4c533

Please sign in to comment.