public void TestFilterPersonViaFullPersonBad() { //SETUP var options = SqliteInMemory.CreateOptions <Chapter01DbContext>(); using (var context = new Chapter01DbContext(options)) { context.Database.EnsureCreated(); context.Add(new Person { FirstName = "John", LastName = "Doe" }); context.SaveChanges(); //ATTEMPT var ex = Assert.Throws <InvalidOperationException>(() => context.Persons.First(x => x.FullName == "John Doe")); //VERIFY ex.Message.ShouldContain("could not be translated."); } }
public void TestPersonReadBackOk() { //SETUP var options = SqliteInMemory.CreateOptions <Chapter01DbContext>(); using (var context = new Chapter01DbContext(options)) { context.Database.EnsureCreated(); context.Add(new Person { FirstName = "John", LastName = "Doe" }); context.SaveChanges(); //ATTEMPT var person = context.Persons.First(); //VERIFY person.FullName.ShouldEqual("John Doe"); } }
public void TestFilterPersonViaFullPersonOk() { //SETUP var options = SqliteInMemory.CreateOptions <Chapter01DbContext>(); using (var context = new Chapter01DbContext(options)) { context.Database.EnsureCreated(); context.Add(new Person { FirstName = "John", LastName = "Doe" }); context.SaveChanges(); //ATTEMPT var query = context.Persons.Where(x => x.FirstName + x.LastName == "JohnDoe"); var person = query.First(); //VERIFY person.ShouldNotBeNull(); _output.WriteLine(query.ToQueryString()); } }