public IEnumerator FieldFilterArrayContains() { yield return(T().YieldWait()); async Task T() { var t1 = TestDocument1.SetAsync <PlayerWithFriends>(new PlayerWithFriends { playerName = "5argon", friends = new object[] { "Suna", "Sompong" }.ToList() }); var t2 = TestDocument2.SetAsync <PlayerWithFriends>(new PlayerWithFriends { playerName = "Suna", friends = new object[] { "5argon", "Shun", "Hydrangea", "Eru" }.ToList() }); var t3 = TestDocument3.SetAsync <PlayerWithFriends>(new PlayerWithFriends { playerName = "Shuno413", friends = new object[] { "Suna", "Reef", "Hydrangea", "5argondesu" }.ToList() }); await Task.WhenAll(new Task[] { t1, t2, t3 }); var snap = await TestCollection.GetSnapshotAsync(("friends", "array_contains", "5argon")); var enu = snap.Documents.GetEnumerator(); Assert.That(snap.Documents.Count(), Is.EqualTo(1)); enu.MoveNext(); var current = enu.Current.ConvertTo <PlayerWithFriends>(); Assert.That(current.playerName, Is.EqualTo("Suna")); } }
public IEnumerator SetGetDocumentMultiple() { yield return(T().YieldWait()); async Task T() { //See what TestDocument1 is in the FirestormTestBase var t1 = TestDocument1.SetAsync <TestDataAB>(new TestDataAB { a = 1, b = "x" }); var t2 = TestDocument2.SetAsync <TestDataAB>(new TestDataAB { a = 2, b = "y" }); var t3 = TestDocument3.SetAsync <TestDataAB>(new TestDataAB { a = 3, b = "z" }); await Task.WhenAll(new Task[] { t1, t2, t3 }); var i1 = (await TestDocument1.GetSnapshotAsync()).ConvertTo <TestDataAB>(); var i2 = (await TestDocument2.GetSnapshotAsync()).ConvertTo <TestDataAB>(); var i3 = (await TestDocument3.GetSnapshotAsync()).ConvertTo <TestDataAB>(); Assert.That(i1.a, Is.EqualTo(1)); Assert.That(i1.b, Is.EqualTo("x")); Assert.That(i2.a, Is.EqualTo(2)); Assert.That(i2.b, Is.EqualTo("y")); Assert.That(i3.a, Is.EqualTo(3)); Assert.That(i3.b, Is.EqualTo("z")); } }
private async Task SetupForQuery() { //Scrambled write order await TestDocument3.SetAsync <TestDataABC>(new TestDataABC { a = 3, b = "z", c = 33.333 }); await TestDocument1.SetAsync <TestDataABC>(new TestDataABC { a = 1, b = "x", c = 11.111 }); await TestDocument2.SetAsync <TestDataABC>(new TestDataABC { a = 2, b = "y", c = 22.222 }); await TestDocument22.SetAsync <TestDataABC>(new TestDataABC { a = 22, b = "yo", c = 222.222 }); await TestDocument21.SetAsync <TestDataABC>(new TestDataABC { a = 21, b = "hey", c = 111.111 }); }
public IEnumerator DocumentReturnedInOrderAndCorrectData() { yield return(T().YieldWait()); async Task T() { await TestDocument2.SetAsync <TestDataAB>(new TestDataAB { a = 2, b = "y" }); await TestDocument1.SetAsync <TestDataAB>(new TestDataAB { a = 1, b = "x" }); await TestDocument3.SetAsync <TestDataAB>(new TestDataAB { a = 3, b = "z" }); //await Task.WhenAll(new Task<TestDataAB>[] { t1, t2, t3 }); var collection = await TestCollection.GetSnapshotAsync(); var enumerator = collection.Documents.GetEnumerator(); //It will be ordered by [ascending document ID](https://firebase.google.com/docs/firestore/query-data/order-limit-data) //Even if we write 2->1->3 we will get 1->2->3 //Custom ordering not supported enumerator.MoveNext(); var doc = enumerator.Current.ConvertTo <TestDataAB>(); Assert.That(doc.a, Is.EqualTo(1)); Assert.That(doc.b, Is.EqualTo("x")); enumerator.MoveNext(); doc = enumerator.Current.ConvertTo <TestDataAB>(); Assert.That(doc.a, Is.EqualTo(2)); Assert.That(doc.b, Is.EqualTo("y")); enumerator.MoveNext(); doc = enumerator.Current.ConvertTo <TestDataAB>(); Assert.That(doc.a, Is.EqualTo(3)); Assert.That(doc.b, Is.EqualTo("z")); } }