public void ConstraintsAreEqualWhenPropertiesAreEqual() { // arrange var first = ExpectedConstraints.CreateManyToMany <Foo, Bar>(f => f.Bars, b => b.Foos); var second = ExpectedConstraints.CreateManyToMany <Foo, Bar>(x => x.Bars, x => x.Foos); // act and assert first.Should().Be(second); }
public void RemovesItemFromCollection() { // arrange var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateManyToMany <Foo, Bar>(f => f.Bars, b => b.Foos)); var foo = fixture.Create <Foo>(); var bar = foo.Bars.First(); // act foo.Bars.Remove(bar); var foos = bar.Foos; // assert foos.Should().NotContain(foo); }
public void AddsItemToDerivedGeneratedCollection() { // arrange var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateManyToMany <Foo, Bar>(f => f.Bars, b => b.Foos)); var foo = fixture.Create <Faz>(); // act var bars = foo.Bars; // assert foreach (var bar in bars) { bar.Foos.Should().Contain(foo); } }
public void ConstraintsShouldBeGenerated() { // arrange var expected = new IPropertyConstraint[] { ExpectedConstraints.CreateManyToMany <Post, Tag>(p => p.Tags, t => t.Posts), ExpectedConstraints.CreateManyToMany <Tag, Post>(t => t.Posts, p => p.Tags), ExpectedConstraints.CreateOneToMany <User, Post>(u => u.Posts, p => p.Poster), ExpectedConstraints.CreateManyToOne <Post, User>(p => p.Poster, u => u.Posts), ExpectedConstraints.CreateOneToOne <User, ContactDetails>(u => u.ContactDetails, c => c.User), ExpectedConstraints.CreateOneToOne <ContactDetails, User>(c => c.User, u => u.ContactDetails), ExpectedConstraints.CreateForeignKey <Post, User, int>(p => p.Poster, p => p.PosterId, u => u.Id), ExpectedConstraints.CreateForeignKey <ContactDetails, User, int>(c => c.User, c => c.UserId, u => u.Id) }; // act var metadata = GetMetadata(); // assert metadata.Constraints.Should().BeEquivalentTo(expected); }