public void Equality() { var client = new FakeFirestoreClient(); var db1 = FirestoreDb.Create("proj", "db", client); var db2 = FirestoreDb.Create("proj", "db", client); var db3 = FirestoreDb.Create("proj", "otherdb", client); var control = db1.Collection("col1/doc1/col2"); var equal = new[] { db1.Collection("col1/doc1/col2"), db2.Collection("col1/doc1/col2"), db1.Collection("col1").Document("doc1").Collection("col2") }; var unequal = new[] { db1.Collection("col1x/doc1/col2"), db1.Collection("col1/doc1x/col2"), db1.Collection("col1/doc1/col2x"), db3.Collection("col1/doc1/col2"), db1.Collection("col1"), db1.Collection("col2"), }; EqualityTester.AssertEqual(control, equal, unequal); }
public async Task CreateAsync() { var client = new FakeFirestoreClient(); var db = await FirestoreDb.CreateAsync("proj", client); Assert.Equal("projects/proj/databases/(default)", db.RootPath); Assert.Equal("projects/proj/databases/(default)/documents", db.DocumentsPath); Assert.Same(client, db.Client); }
public void Create_PublicMethodUsesDefaultDatabase() { var client = new FakeFirestoreClient(); var db = FirestoreDb.Create("proj", client); Assert.Equal("projects/proj/databases/(default)", db.RootPath); Assert.Equal("projects/proj/databases/(default)/documents", db.DocumentsPath); Assert.Same(client, db.Client); }
public void Create_WithDatabase() { var client = new FakeFirestoreClient(); var db = FirestoreDb.Create("proj", "db", client); Assert.Equal("projects/proj/databases/db", db.RootPath); Assert.Equal("projects/proj/databases/db/documents", db.DocumentsPath); Assert.Same(client, db.Client); }
[InlineData("p1", "d1", "col1/doc2", "p1", "d1", "col2/doc1")] // Collection before document // (More details path tests in PathComparerTest) public void CompareTo( string smallerProject, string smallerDb, string smallerPath, string largerProject, string largerDb, string largerPath) { var client = new FakeFirestoreClient(); var smaller = FirestoreDb.Create(smallerProject, smallerDb, client).Document(smallerPath); var larger = FirestoreDb.Create(largerProject, largerDb, client).Document(largerPath); ComparisonTester.AssertComparison(smaller, larger); }
public void CreateTarget_Document() { var client = new FakeFirestoreClient(); var db = FirestoreDb.Create("project", "db", client); var doc = db.Document("col/doc"); var expected = new Target { TargetId = WatchStream.WatchTargetId, Documents = new DocumentsTarget { Documents = { doc.Path } } }; var actual = WatchStream.CreateTarget(doc); Assert.Equal(expected, actual); }
public void CreateTarget_Query() { var client = new FakeFirestoreClient(); var db = FirestoreDb.Create("project", "db", client); var query = db.Collection("col").Limit(10); var expected = new Target { TargetId = WatchStream.WatchTargetId, Query = new QueryTarget { Parent = db.DocumentsPath, StructuredQuery = new StructuredQuery { From = { new CollectionSelector { CollectionId = "col" } }, Limit = 10 } } }; var actual = WatchStream.CreateTarget(query); Assert.Equal(expected, actual); }