Exemple #1
0
        public void AddsItemToGeneratedCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new ManyToOnePropertyConstraint <Foo, Bar>(f => f.Bar, b => b.Foos));
            var foo     = fixture.Create <Foo>();

            // act
            var bar = foo.Bar;

            // assert
            bar.Foos.Should().Contain(foo);
        }
        public void SetsPropertyToGeneratedProxyProperty()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new ForeignKeyConstraint <Foo, Bar, int>(f => f.Bar, f => f.BarId, b => b.Id));
            var foo     = fixture.Create <Foo>();

            // act
            var bar = foo.Bar;

            // assert
            foo.BarId.Should().Be(bar.Id);
        }
Exemple #3
0
        public void SetsNullOnGeneratedProxy()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateManyToOne <Foo, Bar>(f => f.Bar, b => b.Foos));
            var foo     = fixture.Create <Foo>();

            // act
            foo.Bar = null;

            // assert
            foo.Bar.Should().BeNull();
        }
Exemple #4
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);
        }
Exemple #5
0
        public void SetsInversePropertyOnProxyAddedToGeneratedCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new OneToManyPropertyConstraint <Foo, Bar>(f => f.Bars, b => b.Foo));
            var foo     = fixture.Create <Foo>();
            var bar     = fixture.Create <Bar>();

            // act
            foo.Bars.Add(bar);

            // assert
            bar.Foo.Should().BeSameAs(foo);
        }
        public void SetsInversePropertyOnPOCO()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new OneToOnePropertyConstraint <Foo, Bar>(f => f.Bar, b => b.Foo));
            var foo     = fixture.Create <Foo>();
            var bar     = new Bar();

            // act
            foo.Bar = bar;

            // assert
            bar.Foo.Should().BeSameAs(foo);
        }
        public void SetsNullOnGeneratedProxy()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new OneToOnePropertyConstraint <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();
        }
Exemple #8
0
        public void RemovesItemFromCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateManyToOne <Foo, Bar>(f => f.Bar, b => b.Foos));
            var foo     = fixture.Create <Foo>();
            var bar     = foo.Bar;

            // act
            foo.Bar = fixture.Create <Bar>();

            // assert
            bar.Foos.Should().NotContain(foo);
        }
Exemple #9
0
        public void AddsItemToPOCOCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateManyToOne <Foo, Bar>(f => f.Bar, b => b.Foos));
            var foo     = fixture.Create <Foo>();
            var bar     = new Bar();

            // act
            foo.Bar = bar;

            // assert
            bar.Foos.Should().Contain(foo);
        }
        public void SetsPropertyToNull()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateForeignKey <Foo, Bar, int>(f => f.Bar, f => f.BarId, b => b.Id));
            var foo     = fixture.Create <Foo>();
            Bar bar     = null;

            // act
            foo.Bar = bar;

            // assert
            foo.BarId.Should().Be(0);
        }
        public void RemovesItemFromCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new ManyToManyPropertyConstraint <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);
        }
Exemple #12
0
        public void SetsInversePropertyOnExternalCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new OneToManyPropertyConstraint <Foo, Bar>(f => f.Bars, b => b.Foo));
            var foo     = fixture.Create <Foo>();

            // act
            foo.Bars = fixture.Create <ICollection <Bar> >();

            // assert
            foreach (var bar in foo.Bars)
            {
                bar.Foo.Should().BeSameAs(foo);
            }
        }
        public void AddsItemToDerivedGeneratedCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new ManyToManyPropertyConstraint <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 SetsInversePropertyOnDerivedGeneratedCollection()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(ExpectedConstraints.CreateOneToMany <Foo, Bar>(f => f.Bars, b => b.Foo));
            var foo     = fixture.Create <Faz>();

            // act
            var bars = foo.Bars;

            // assert
            foreach (var bar in bars)
            {
                bar.Foo.Should().BeSameAs(foo);
            }
        }
        public void SetsDerivedPropertyToPOCOProperty()
        {
            // arrange
            var fixture = IntegrationTest.GetFixture(new ForeignKeyConstraint <Foo, Bar, int>(f => f.Bar, f => f.BarId, b => b.Id));
            var foo     = fixture.Create <Faz>();
            var bar     = new Bar()
            {
                Id = fixture.Create <int>()
            };

            // act
            foo.Bar = bar;

            // assert
            foo.BarId.Should().Be(bar.Id);
        }