-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support object value in
BoxConflictErrorContextInfo
- Loading branch information
Showing
7 changed files
with
122 additions
and
0 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,50 @@ | ||
using Box.V2.Converter; | ||
using Box.V2.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Box.V2.Test | ||
{ | ||
[TestClass] | ||
public class SingleOrCollectionConverterTest : BoxResourceManagerTest | ||
{ | ||
private readonly IBoxConverter _converter; | ||
|
||
public SingleOrCollectionConverterTest() | ||
{ | ||
_converter = new BoxJsonConverter(); | ||
} | ||
|
||
[TestMethod] | ||
public void SingleObject() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/SingleObject.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts[0].Name, "Test Folder"); | ||
} | ||
|
||
[TestMethod] | ||
public void Array() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/Array.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts[0].Name, "Test Folder"); | ||
Assert.AreEqual(error.Conflicts[1].Name, "Test Folder 2"); | ||
} | ||
|
||
[TestMethod] | ||
public void EmptyArray() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/EmptyArray.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts.Count, 0); | ||
} | ||
|
||
[TestMethod] | ||
public void Empty() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/Empty.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.IsNull(error.Conflicts); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Box.V2.Test/Fixtures/Converters/SingleOrCollectionConverter/Array.json
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,18 @@ | ||
{ | ||
"conflicts": [ | ||
{ | ||
"type": "folder", | ||
"id": "123", | ||
"sequence_id": "0", | ||
"etag": "0", | ||
"name": "Test Folder" | ||
}, | ||
{ | ||
"type": "folder", | ||
"id": "124", | ||
"sequence_id": "0", | ||
"etag": "0", | ||
"name": "Test Folder 2" | ||
} | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
Box.V2.Test/Fixtures/Converters/SingleOrCollectionConverter/Empty.json
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,2 @@ | ||
{ | ||
} |
4 changes: 4 additions & 0 deletions
4
Box.V2.Test/Fixtures/Converters/SingleOrCollectionConverter/EmptyArray.json
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,4 @@ | ||
{ | ||
"conflicts": [ | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
Box.V2.Test/Fixtures/Converters/SingleOrCollectionConverter/SingleObject.json
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,9 @@ | ||
{ | ||
"conflicts": { | ||
"type": "folder", | ||
"id": "123", | ||
"sequence_id": "0", | ||
"etag": "0", | ||
"name": "Test Folder" | ||
} | ||
} |
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