public async Task TestUploadBlobUsingUniversal() { // Arrange var urlExpected = @"https://titlestorage.xboxlive.com/universalplatform/users/xuid(2814662072777140)/scids/00000000-0000-0000-0000-0000694f5acb/data/queststatus/quest01.json,json"; MockXboxLiveData.MockRequestData uploadRequestData = MockXboxLiveData.MockResponses["UniversalPlatformUploadBlob"]; var titleBlobMetadata = new TitleStorageBlobMetadata(TitleStorageType.UniversalPlatform, @"queststatus/quest01.json", TitleStorageBlobType.Json); var uploadedQuest = new Quest { QuestName = "Quest 01", CharactersInvolved = new List <string>() { "Character 01", "Character 02", "Character 03" } }; var testQuestJson = JsonSerialization.ToJson(uploadedQuest); var blobBuffer = Encoding.ASCII.GetBytes(testQuestJson).ToList(); var blobQueryProperties = new BlobQueryProperties(); // Act await this.titleStorageService.UploadBlobAsync(user, titleBlobMetadata, blobBuffer, blobQueryProperties); // Assert Assert.AreEqual("PUT", uploadRequestData.Request.Method); Assert.AreEqual(urlExpected, uploadRequestData.Request.Url); }
public async Task GetLeaderboard() { LeaderboardQuery query = new LeaderboardQuery { StatName = "Jumps", MaxItems = 100, }; LeaderboardResult result = await this.leaderboardService.GetLeaderboardAsync(this.user, query); MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["defaultLeaderboardData"]; JObject responseJson = JObject.Parse(mockRequestData.Response.ResponseBodyString); Assert.AreEqual("GET", mockRequestData.Request.Method); Assert.AreEqual("https://leaderboards.xboxlive.com/scids/00000000-0000-0000-0000-0000694f5acb/leaderboards/stat(Jumps)?maxItems=100", mockRequestData.Request.Url); Assert.IsTrue(result.HasNext); VerifyLeaderboardResult(result, responseJson); // Testing continuation token with GetNext. LeaderboardQuery nextQuery = new LeaderboardQuery(query, "6"); LeaderboardResult nextResult = await this.leaderboardService.GetLeaderboardAsync(this.user, nextQuery); MockXboxLiveData.MockRequestData mockRequestDataWithContinuationToken = MockXboxLiveData.MockResponses["defaultLeaderboardDataWithContinuationToken"]; JObject responseJsonWithContinuationToken = JObject.Parse(mockRequestDataWithContinuationToken.Response.ResponseBodyString); Assert.AreEqual("GET", mockRequestDataWithContinuationToken.Request.Method); Assert.AreEqual("https://leaderboards.xboxlive.com/scids/00000000-0000-0000-0000-0000694f5acb/leaderboards/stat(Jumps)?maxItems=100&continuationToken=6", mockRequestDataWithContinuationToken.Request.Url); Assert.IsFalse(nextResult.HasNext); VerifyLeaderboardResult(nextResult, responseJsonWithContinuationToken); }
public async Task CheckPermissionWithTargetUserAsync() { PermissionCheckResult result = await this.user.Services.PrivacyService.CheckPermissionWithTargetUserAsync(PermissionIdConstants.ViewTargetVideoHistory, "2814680291986301"); MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["defaultCheckPermissionsResponse"]; JObject responseJson = JObject.Parse(mockRequestData.Response.ResponseBodyString); Assert.AreEqual("GET", mockRequestData.Request.Method); Assert.AreEqual("https://privacy.xboxlive.com/users/xuid(2814662072777140)/permission/validate?setting=ViewTargetVideoHistory&target=xuid(2814680291986301)", mockRequestData.Request.Url); VerifyPermissionCheckResult(result, responseJson); }
public async Task TestDeleteBlobUsingUniversal() { // Arrange var urlExpected = @"https://titlestorage.xboxlive.com/universalplatform/users/xuid(2814662072777140)/scids/00000000-0000-0000-0000-0000694f5acb/data/queststatus/quest01.json,json"; MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["UniversalPlatformDeleteBlob"]; var titleBlobMetadata = new TitleStorageBlobMetadata(TitleStorageType.UniversalPlatform, @"queststatus/quest01.json", TitleStorageBlobType.Json); var blobQueryProperties = new BlobQueryProperties(); // Act await this.titleStorageService.DeleteBlobAsync(user, titleBlobMetadata, blobQueryProperties); // Assert Assert.AreEqual("DELETE", mockRequestData.Request.Method); Assert.AreEqual(urlExpected, mockRequestData.Request.Url); }
public async Task TestGetQuotaAsyncWithUniversalStorage() { // Arrange var urlExpected = @"https://titlestorage.xboxlive.com/universalplatform/users/xuid(2814662072777140)/scids/00000000-0000-0000-0000-0000694f5acb"; MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["UniversalPlatformGetQuota"]; var responseJson = JObject.Parse(mockRequestData.Response.ResponseBodyString); // Act var titleStorageQuota = await this.titleStorageService.GetQuotaAsync(user, TitleStorageType.UniversalPlatform); // Assert Assert.AreEqual("GET", mockRequestData.Request.Method); Assert.AreEqual(urlExpected, mockRequestData.Request.Url); Assert.AreEqual(TitleStorageType.UniversalPlatform, titleStorageQuota.StorageType); VerifyTitleStorageQuotaResult(titleStorageQuota, responseJson); }
public async Task TestUploadBlobUsingUniversalUsingBinaryAndContentLength() { // Arrange var url1Expected = @"https://titlestorage.xboxlive.com/universalplatform/users/xuid(2814662072777140)/scids/00000000-0000-0000-0000-0000694f5acb/data/file.bin,binary?finalBlock=True"; MockXboxLiveData.MockRequestData uploadRequestData = MockXboxLiveData.MockResponses["UniversalPlatformUploadBinary01"]; var titleBlobMetadata = new TitleStorageBlobMetadata(TitleStorageType.UniversalPlatform, @"file.bin", TitleStorageBlobType.Binary); var longText = "< p >Lorem ipsum dolor sit amet, netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.Donec eu libero sit amet quam egestas semper. Aenean"; var blobBuffer = Encoding.ASCII.GetBytes(longText).ToList(); var blobQueryProperties = new BlobQueryProperties(); // Act await this.titleStorageService.UploadBlobAsync(user, titleBlobMetadata, blobBuffer, blobQueryProperties); // Assert Assert.AreEqual("PUT", uploadRequestData.Request.Method); Assert.AreEqual(url1Expected, uploadRequestData.Request.Url); }
public async Task TestDownloadBlobUsingUniversal() { // Arrange var urlExpected = @"https://titlestorage.xboxlive.com/universalplatform/users/xuid(2814662072777140)/scids/00000000-0000-0000-0000-0000694f5acb/data/queststatus/quest01.json,json"; MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["UniversalPlatformDownloadBlob"]; var responseJson = JObject.Parse(mockRequestData.Response.ResponseBodyString); var titleBlobMetadata = new TitleStorageBlobMetadata(TitleStorageType.UniversalPlatform, @"queststatus/quest01.json", TitleStorageBlobType.Json); var blobQueryProperties = new BlobQueryProperties(); // Act var downloadBlobResult = await this.titleStorageService.DownloadBlobAsync(user, titleBlobMetadata, blobQueryProperties); var downloadBlobString = Encoding.Default.GetString(downloadBlobResult.BlobBuffer.ToArray()); var downloadedQuest = JsonSerialization.FromJson <Quest>(downloadBlobString); // Assert Assert.AreEqual("GET", mockRequestData.Request.Method); Assert.AreEqual(urlExpected, mockRequestData.Request.Url); VerifyDownloadQuest(downloadedQuest, responseJson); }
public async Task CheckMultiplePermissionsWithMultipleTargetUsersAsync() { List <string> permissionIds = new List <string>(); permissionIds.Add(PermissionIdConstants.ViewTargetVideoHistory); permissionIds.Add(PermissionIdConstants.ViewTargetMusicStatus); permissionIds.Add(PermissionIdConstants.ViewTargetGameHistory); List <string> xuids = new List <string>(); xuids.Add("2814680291986301"); xuids.Add("2814634309691161"); List <MultiplePermissionsCheckResult> result = await this.user.Services.PrivacyService.CheckMultiplePermissionsWithMultipleTargetUsersAsync(permissionIds, xuids); MockXboxLiveData.MockRequestData mockRequestData = MockXboxLiveData.MockResponses["defaultCheckMultiplePermissionsResponse"]; JObject responseJson = JObject.Parse(mockRequestData.Response.ResponseBodyString); Assert.AreEqual("POST", mockRequestData.Request.Method); Assert.AreEqual("https://privacy.xboxlive.com/users/xuid(2814662072777140)/permission/validate", mockRequestData.Request.Url); VerifyMultiplePermissionsCheckResult(result, responseJson); }