public void Equality()
        {
            var query    = s_db.Collection("col1");
            var readTime = new Timestamp(10, 2);
            var doc1     = GetSampleSnapshot(s_db, "doc1");
            var doc2     = GetSampleSnapshot(s_db, "doc2");
            var doc3     = GetSampleSnapshot(s_db, "doc3");

            var docs    = new[] { doc1, doc2 };
            var control = QuerySnapshot.ForDocuments(query, docs, readTime);

            EqualityTester.AssertEqual(control,
                                       // Distinct but equal values for query and snapshots, but a different timestamp
                                       equal: new[] { QuerySnapshot.ForDocuments(s_db.Collection("col1"), new[] { GetSampleSnapshot(s_db, "doc1"), doc2 }, new Timestamp(12, 13)) },
                                       unequal: new[] {
                // Unequal query
                QuerySnapshot.ForDocuments(query.Offset(0), docs, readTime),
                // No doc2
                QuerySnapshot.ForDocuments(query, new[] { doc1 }, readTime),
                // Extra doc3
                QuerySnapshot.ForDocuments(query, new[] { doc1, doc2, doc3 }, readTime),
                // Order matters
                QuerySnapshot.ForDocuments(query, new[] { doc2, doc1 }, readTime),
            });

            // Note: no test for the changes being compared. It would be overkill at the moment.
        }
        public void ConvenienceMembers()
        {
            var db       = FirestoreDb.Create("proj", "db", new FakeFirestoreClient());
            var query    = db.Collection("col1");
            var readTime = new Timestamp(10, 2);
            var doc1     = DocumentSnapshot.ForMissingDocument(db, "projects/proj/databases/db/documents/col1/doc1", readTime);
            var proto    = new Document
            {
                CreateTime = CreateProtoTimestamp(1, 10),
                UpdateTime = CreateProtoTimestamp(2, 20),
                Name       = "projects/proj/databases/db/documents/col1/doc2"
            };
            var doc2 = DocumentSnapshot.ForDocument(db, proto, readTime);
            var docs = new[] { doc1, doc2 };

            var querySnapshot = QuerySnapshot.ForDocuments(query, docs, readTime);

            Assert.Equal(2, querySnapshot.Count);
            // Indexer
            Assert.Same(doc1, querySnapshot[0]);
            Assert.Same(doc2, querySnapshot[1]);
            Assert.Throws <ArgumentOutOfRangeException>(() => querySnapshot[-1]);
            Assert.Throws <ArgumentOutOfRangeException>(() => querySnapshot[2]);
            // Use IEnumerable<DocumentSnapshot>
            Assert.Equal(docs, querySnapshot);
            // OfType forces the use of non-generic IEnumerable
            Assert.Equal(docs, querySnapshot.OfType <DocumentSnapshot>());
        }
        public void GeneratedChanges()
        {
            var query    = s_db.Collection("col1");
            var readTime = new Timestamp(10, 2);
            var doc1     = GetSampleSnapshot(s_db, "doc1");
            var doc2     = GetSampleSnapshot(s_db, "doc2");
            var snapshot = QuerySnapshot.ForDocuments(query, new[] { doc1, doc2 }, readTime);

            Assert.Equal(new DocumentChange(doc1, DocumentChange.Type.Added, null, 0), snapshot.Changes[0]);
            Assert.Equal(new DocumentChange(doc2, DocumentChange.Type.Added, null, 1), snapshot.Changes[1]);
        }