1+ using System ;
2+ using System . Collections . Specialized ;
3+ using NUnit . Framework ;
4+ using XboxWebApi . Common ;
5+ using XboxWebApi . Extensions ;
6+ using XboxWebApi . Services . Model ;
7+
8+ namespace XboxWebApi . UnitTests . Api
9+ {
10+ [ TestFixture ]
11+ public class TestProfileModels : TestDataProvider
12+ {
13+ public TestProfileModels ( )
14+ : base ( "ApiProfile" )
15+ {
16+ }
17+
18+ [ Test ]
19+ public void CreateProfileRequestQuery ( )
20+ {
21+ ProfileRequestQuery query = new ProfileRequestQuery ( new ProfileSetting [ ]
22+ {
23+ ProfileSetting . AccountTier ,
24+ ProfileSetting . GameDisplayName ,
25+ ProfileSetting . PublicGamerpic
26+ } ) ;
27+ NameValueCollection nv = query . GetQuery ( ) ;
28+
29+ Assert . IsNotEmpty ( nv ) ;
30+ Assert . AreEqual ( 1 , nv . Count ) ;
31+ Assert . AreEqual ( "AccountTier,GameDisplayName,PublicGamerpic" , nv [ "settings" ] ) ;
32+ }
33+
34+ [ Test ]
35+ public void DeserializeProfileResponse ( )
36+ {
37+ string json = TestData [ "ProfileResponse.json" ] ;
38+ ProfileResponse response = NewtonsoftJsonSerializer
39+ . Create ( JsonNamingStrategy . CamelCase )
40+ . Deserialize < ProfileResponse > ( json ) ;
41+
42+ Assert . IsInstanceOf ( typeof ( IStringable ) , response ) ;
43+
44+ Assert . IsNotNull ( response . ProfileUsers ) ;
45+ Assert . IsNotEmpty ( response . ProfileUsers ) ;
46+ Assert . AreEqual ( 1 , response . ProfileUsers . Length ) ;
47+
48+ Assert . AreEqual ( 2580478784034343 , response . ProfileUsers [ 0 ] . Id ) ;
49+ Assert . AreEqual ( 2580478784034343 , response . ProfileUsers [ 0 ] . HostId ) ;
50+ Assert . IsFalse ( response . ProfileUsers [ 0 ] . IsSponsoredUser ) ;
51+ Assert . IsNotNull ( response . ProfileUsers [ 0 ] . Settings ) ;
52+ Assert . IsNotEmpty ( response . ProfileUsers [ 0 ] . Settings ) ;
53+ Assert . AreEqual ( 6 , response . ProfileUsers [ 0 ] . Settings . Length ) ;
54+
55+ Assert . AreEqual ( ProfileSetting . AppDisplayName , response . ProfileUsers [ 0 ] . Settings [ 0 ] . Id ) ;
56+ Assert . AreEqual ( "Some Gamertag" , response . ProfileUsers [ 0 ] . Settings [ 0 ] . Value ) ;
57+ Assert . AreEqual ( ProfileSetting . Gamerscore , response . ProfileUsers [ 0 ] . Settings [ 1 ] . Id ) ;
58+ Assert . AreEqual ( "1337000" , response . ProfileUsers [ 0 ] . Settings [ 1 ] . Value ) ;
59+ Assert . AreEqual ( ProfileSetting . Gamertag , response . ProfileUsers [ 0 ] . Settings [ 2 ] . Id ) ;
60+ Assert . AreEqual ( "Some Gamertag" , response . ProfileUsers [ 0 ] . Settings [ 2 ] . Value ) ;
61+ Assert . AreEqual ( ProfileSetting . PublicGamerpic , response . ProfileUsers [ 0 ] . Settings [ 3 ] . Id ) ;
62+ Assert . AreEqual ( "http://images-eds.xboxlive.com/image?url=abcdef" ,
63+ response . ProfileUsers [ 0 ] . Settings [ 3 ] . Value ) ;
64+ Assert . AreEqual ( ProfileSetting . XboxOneRep , response . ProfileUsers [ 0 ] . Settings [ 4 ] . Id ) ;
65+ Assert . AreEqual ( "Superstar" , response . ProfileUsers [ 0 ] . Settings [ 4 ] . Value ) ;
66+ Assert . AreEqual ( ProfileSetting . RealName , response . ProfileUsers [ 0 ] . Settings [ 5 ] . Id ) ;
67+ Assert . AreEqual ( "John Doe" , response . ProfileUsers [ 0 ] . Settings [ 5 ] . Value ) ;
68+ }
69+ }
70+ }
0 commit comments