private CFCompatibilityTestSubject <string> AssertSubject(string name) { CFCompatibilityTestSubject <string> instance = RetrieveOnlyInstance(name); Assert.AreEqual(Subjects.Item(name), instance); return(instance); }
public void TestUpdate() { CFCompatibilityTestSubject <string> foobar = AssertSubject("foobar"); Assert.AreEqual(Subjects.Item("baz"), foobar._child); foobar.Child(RetrieveOnlyInstance("bar")); Db().Store(foobar); }
private static int ValidateDatabase(string databaseFile) { int errorCount = 0; using (IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), databaseFile)) { IList <CFCompatibilityTestSubject <string> > results = db.Query <CFCompatibilityTestSubject <string> >(delegate(CFCompatibilityTestSubject <string> candidate) { return(candidate._name == "foo"); }); if (results.Count > 0) { Console.Error.WriteLine("Object with name 'foo' should be deleted but still exists in db."); errorCount++; } const string johnDoeName = "john.doe"; CFCompatibilityTestSubject <string> subject = RetrieveOnlyInstance(db, johnDoeName); if (null == subject) { errorCount++; } CFCompatibilityTestSubject <string> expected = Subjects.NewJohnDoe(); if (!expected.Equals(subject)) { Console.Error.WriteLine("Expected {0} but got {1}", expected, subject != null ? subject.ToString() : "null"); errorCount++; } subject = RetrieveOnlyInstance(db, "foobar"); if (null == subject) { errorCount++; } if (!Subjects.Item("bar").Equals(subject._child)) { Console.Error.WriteLine("Foo._child expected to be {0} but was {1}", Subjects.Item("bar"), subject._child); errorCount++; } } return(errorCount); }