forked from anthonyreilly/NetCoreForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNullValueTests.cs
63 lines (53 loc) · 2.22 KB
/
NullValueTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Xunit;
using NetCoreForce.Client;
using NetCoreForce.Client.Models;
using NetCoreForce.Models;
using Newtonsoft.Json;
namespace NetCoreForce.FunctionalTests
{
public class NullValueTests : IClassFixture<ForceClientFixture>
{
ForceClientFixture forceClientFixture;
public NullValueTests(ForceClientFixture fixture)
{
this.forceClientFixture = fixture;
}
[Fact]
public async Task FieldsToNullTest()
{
ForceClient client = await forceClientFixture.GetForceClient();
CreateResponse createResp = await client.CreateRecord<SfAccount>(SfAccount.SObjectTypeName,
new SfAccount()
{
Name = "test account",
Description = "test description",
BillingCity = "anytown"
});
Assert.True(!string.IsNullOrEmpty(createResp.Id), "Failed to create new object");
//get newly created
string accountId = createResp.Id;
SfAccount account = await client.GetObjectById<SfAccount>(SfAccount.SObjectTypeName, accountId);
Assert.True(account != null, "Failed to retrieve new object");
Assert.NotNull(account.Description);
Assert.NotNull(account.BillingCity);
//update object
account.Description = null;
account.BillingCity = null;
List<string> fieldsToNull = new List<string>() { "description" };
await client.UpdateRecord<SfAccount>(SfAccount.SObjectTypeName, account.Id, account, fieldsToNull: fieldsToNull);
//get newly updated
SfAccount udpatedAccount = await client.GetObjectById<SfAccount>(SfAccount.SObjectTypeName, accountId);
Assert.True(udpatedAccount != null, "Failed to retrieve udpated object");
//delete
await client.DeleteRecord(SfAccount.SObjectTypeName, accountId);
// We're expecting only description to be set to null
Assert.Null(udpatedAccount.Description);
Assert.NotNull(udpatedAccount.BillingCity);
}
}
}