Menu

[r1586]: / trunk / UnitTests / GoogleContactBuilder.cs  Maximize  Restore  History

Download this file

63 lines (56 with data), 2.2 kB

 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
using Google.Apis.PeopleService.v1.Data;
using System.Collections.Generic;
namespace GoContactSyncMod.UnitTests
{
public class GoogleContactBuilder
{
public Person Build()
{
return new Person();
}
public Person Build(string bio)
{
var newEntry = new Person();
var name = ContactPropertiesUtils.GetGooglePrimaryName(newEntry);
if (name == null)
{
name = new Name();
if (newEntry.Names == null)
newEntry.Names = new List<Name>();
newEntry.Names.Add(name);
}
name.UnstructuredName = SyncContactsTests.TEST_CONTACT_NAME;
var primaryEmail = new EmailAddress
{
Value = SyncContactsTests.TEST_CONTACT_EMAIL,
Metadata = new FieldMetadata { Primary = true },
Type = ContactSync.WORK
};
if (newEntry.EmailAddresses == null)
newEntry.EmailAddresses = new List<EmailAddress>();
newEntry.EmailAddresses.Add(primaryEmail);
var phoneNumber = new PhoneNumber
{
Value = "555-555-5551",
Metadata = new FieldMetadata { Primary = true },
Type = ContactSync.PHONE_MOBILE
};
if (newEntry.PhoneNumbers == null)
newEntry.PhoneNumbers = new List<PhoneNumber>();
newEntry.PhoneNumbers.Add(phoneNumber);
var address = new Address
{
StreetAddress = "123 somewhere lane",
Metadata = new FieldMetadata { Primary = true },
Type = ContactSync.HOME
};
if (newEntry.Addresses == null)
newEntry.Addresses = new List<Address>();
newEntry.Addresses.Add(address);
if (newEntry.Biographies == null)
newEntry.Biographies = new List<Biography>();
newEntry.Biographies.Add(new Biography { Value = bio });
return newEntry;
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.