Beispiel #1
0
        public void ConstraintsAreEqualWhenPropertiesAreEqual()
        {
            // arrange
            var first  = ExpectedConstraints.CreateOneToOne <Foo, Bar>(f => f.Bar, b => b.Foo);
            var second = ExpectedConstraints.CreateOneToOne <Foo, Bar>(x => x.Bar, x => x.Foo);

            // act and assert
            first.Should().Be(second);
        }
Beispiel #2
0
        public void SetsInversePropertyOnDerivedGeneratedProxy()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateOneToOne <Foo, Bar>(f => f.Bar, b => b.Foo));
            var foo     = fixture.Create <Faz>();

            // act
            var bar = foo.Bar;

            // assert
            bar.Foo.Should().BeSameAs(foo);
        }
Beispiel #3
0
        public void SetsNullOnGeneratedProxy()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateOneToOne <Foo, Bar>(f => f.Bar, b => b.Foo));
            var foo     = fixture.Create <Foo>();
            var bar     = foo.Bar;

            // act
            foo.Bar = null;

            // assert
            foo.Bar.Should().BeNull();
        }
        public void ConstraintsShouldBeGenerated()
        {
            // arrange
            var expected = new IPropertyConstraint[]
            {
                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);
        }