public void Should_Save(TestContextFixture testContextFixture, Post post) { testContextFixture.Save(post); Post saved = null; testContextFixture.DoClean((context) => saved = context.Set <Post>() .Include(s => s.From) .SingleOrDefault(s => s.Content == post.Content)); saved.ShouldNotBeNull(); saved.From.ShouldNotBeNull(); }
public void Should_SaveCustomer(TestContextFixture testContextFixture, User user) { testContextFixture.Save(user); User saved = null; testContextFixture.DoClean((context) => saved = context.Set <User>() .Include(s => s.Posts) .SingleOrDefault(s => s.LastName == user.LastName)); saved.ShouldNotBeNull(); saved.Posts.ShouldNotBeNull(); }
public void ConcurrentUserNameChanged_ShouldThrow(TestContextFixture testContextFixture, User user, UpdateUser.Command updateUser) { //arrange testContextFixture.Save(user); user.FirstName = "Piet"; testContextFixture.DoClean(db => db.Database.ExecuteSqlCommand("UPDATE dbo.Users set firstname='Karel'") ); //act & assert Should.Throw <DbUpdateConcurrencyException>(() => testContextFixture.SendAsync(updateUser) ); }