public IEnumerator DocumentReference_TasksFailProperly() { var docWithInvalidName = TestCollection().Document("__badpath__"); var fieldPathData = new Dictionary <FieldPath, object> { { new FieldPath("key"), 42 } }; { Task task = docWithInvalidName.DeleteAsync(); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task task = docWithInvalidName.UpdateAsync(TestData(0)); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task task = docWithInvalidName.UpdateAsync("fieldName", 42); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task task = docWithInvalidName.UpdateAsync(fieldPathData); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task task = docWithInvalidName.SetAsync(TestData(), SetOptions.MergeAll); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task <DocumentSnapshot> task = docWithInvalidName.GetSnapshotAsync(); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { Task <DocumentSnapshot> task = docWithInvalidName.GetSnapshotAsync(Source.Default); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { ListenerRegistration listenerRegistration = docWithInvalidName.Listen(snap => {}); yield return(AwaitCompletion(listenerRegistration.ListenerTask)); AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument); listenerRegistration.Stop(); } }
public void LeaveGame(string gameId, string username, Action <StatusCode> completion) { DocumentReference gameRef = db.Collection("games").Document(gameId); StatusCode transactionStatus = StatusCode.OK; db.RunTransactionAsync(async transaction => { DocumentSnapshot game = await transaction.GetSnapshotAsync(gameRef); if (!game.Exists) { transactionStatus = StatusCode.UNKNWON; return(false); } GameState gameState = game.ConvertTo <GameState>(); if (gameState.PlayerX == username) { gameState.PlayerX = null; } if (gameState.PlayerO == username) { gameState.PlayerO = null; } if (_gameUpdateListener != null) { _gameUpdateListener.Stop(); } if (_chatUpdateListener != null) { _chatUpdateListener.Stop(); } if (gameState.IsEmpty) { transaction.Delete(gameRef); } else { transaction.Set(gameRef, gameState); } return(true); }).ContinueWithOnMainThread(taks => { completion(transactionStatus); }); }
public IEnumerator CollectionReference_TasksFailProperly() { var collectionWithInvalidName = TestCollection().Document("__badpath__").Collection("sub"); { Task <QuerySnapshot> task = collectionWithInvalidName.GetSnapshotAsync(); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument, "__badpath__"); } { Task <QuerySnapshot> task = collectionWithInvalidName.GetSnapshotAsync(Source.Default); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument, "__badpath__"); } { Task <DocumentReference> task = collectionWithInvalidName.AddAsync(TestData(0)); yield return(AwaitCompletion(task)); AssertTaskFaulted(task, FirestoreError.InvalidArgument); } { ListenerRegistration listenerRegistration = collectionWithInvalidName.Listen(snap => {}); yield return(AwaitCompletion(listenerRegistration.ListenerTask)); AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); listenerRegistration.Stop(); } { ListenerRegistration listenerRegistration = collectionWithInvalidName.Listen(MetadataChanges.Include, snap => {}); yield return(AwaitCompletion(listenerRegistration.ListenerTask)); AssertTaskFaulted(listenerRegistration.ListenerTask, FirestoreError.InvalidArgument, "__badpath__"); listenerRegistration.Stop(); } }
public void Unlisten() { listener.Stop(); }