Skip to content

Commit

Permalink
test: Add test for device pinners (box/box-codegen#443) (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored Mar 6, 2024
1 parent c2978b6 commit 98bcbd3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "9f6df0d", "specHash": "b2f7568", "version": "0.1.0" }
{ "engineHash": "9836a44", "specHash": "b2f7568", "version": "0.1.0" }
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial
var attribute = Attribute.GetCustomAttribute(field,
typeof(DescriptionAttribute)) as DescriptionAttribute;

if (attribute?.Description == document.RootElement.ToString())
if (attribute?.Description.ToLower() == document.RootElement.ToString().ToLower())
{
return (T)field.GetValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NullableExtensions;
using System;
using Box.Sdk.Gen;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Managers;

namespace Box.Sdk.Gen.Tests.Integration {
[TestClass]
public class DevicePinnersManagerTests {
public BoxClient client { get; }

public DevicePinnersManagerTests() {
client = new CommonsManager().GetDefaultClient();
}
[TestMethod]
public async System.Threading.Tasks.Task TestDevicePinners() {
string enterpriseId = Utils.GetEnvVar(name: "ENTERPRISE_ID");
DevicePinners devicePinners = await client.DevicePinners.GetEnterpriseDevicePinnersAsync(enterpriseId: enterpriseId).ConfigureAwait(false);
Assert.IsTrue(NullableUtils.Unwrap(devicePinners.Entries).Count >= 0);
DevicePinners devicePinnersInDescDirection = await client.DevicePinners.GetEnterpriseDevicePinnersAsync(enterpriseId: enterpriseId, queryParams: new GetEnterpriseDevicePinnersQueryParams() { Direction = GetEnterpriseDevicePinnersQueryParamsDirectionField.Desc }).ConfigureAwait(false);
Assert.IsTrue(NullableUtils.Unwrap(devicePinnersInDescDirection.Entries).Count >= 0);
const string devicePinnerId = "123456";
await Assert.That.IsExceptionAsync(async() => await client.DevicePinners.GetDevicePinnerByIdAsync(devicePinnerId: devicePinnerId).ConfigureAwait(false));
await Assert.That.IsExceptionAsync(async() => await client.DevicePinners.DeleteDevicePinnerByIdAsync(devicePinnerId: devicePinnerId).ConfigureAwait(false));
}

}
}
2 changes: 1 addition & 1 deletion Box.Sdk.Gen/Serialization/Json/Serializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial
var attribute = Attribute.GetCustomAttribute(field,
typeof(DescriptionAttribute)) as DescriptionAttribute;

if (attribute?.Description == document.RootElement.ToString())
if (attribute?.Description.ToLower() == document.RootElement.ToString().ToLower())
{
return (T)field.GetValue(null);
}
Expand Down
15 changes: 12 additions & 3 deletions docs/DevicePinners.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ This operation is performed by calling function `GetDevicePinnerById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-device-pinners-id/).

*Currently we don't have an example for calling `GetDevicePinnerById` in integration tests*
<!-- sample get_device_pinners_id -->
```
await client.DevicePinners.GetDevicePinnerByIdAsync(devicePinnerId: devicePinnerId).ConfigureAwait(false)
```

### Arguments

Expand Down Expand Up @@ -42,7 +45,10 @@ This operation is performed by calling function `DeleteDevicePinnerById`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/delete-device-pinners-id/).

*Currently we don't have an example for calling `DeleteDevicePinnerById` in integration tests*
<!-- sample delete_device_pinners_id -->
```
await client.DevicePinners.DeleteDevicePinnerByIdAsync(devicePinnerId: devicePinnerId).ConfigureAwait(false)
```

### Arguments

Expand Down Expand Up @@ -73,7 +79,10 @@ This operation is performed by calling function `GetEnterpriseDevicePinners`.
See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-enterprises-id-device-pinners/).

*Currently we don't have an example for calling `GetEnterpriseDevicePinners` in integration tests*
<!-- sample get_enterprises_id_device_pinners -->
```
await client.DevicePinners.GetEnterpriseDevicePinnersAsync(enterpriseId: enterpriseId, queryParams: new GetEnterpriseDevicePinnersQueryParams(direction: GetEnterpriseDevicePinnersQueryParamsDirectionField.Desc)).ConfigureAwait(false)
```

### Arguments

Expand Down

0 comments on commit 98bcbd3

Please sign in to comment.