Exemple #1
0
        public void Can_Use_Nested_Builder()
        {
            var builder = new BuilderForTesting <ExampleClass>();

            builder.SetProperty <ExampleReferencedClassBuilder>(x => x.ReferenceProp);
            ExampleReferencedClass res = builder.GetProperty(x => x.ReferenceProp, () => null);

            res.Should().NotBeNull("Nested builder should create an instance.");
        }
Exemple #2
0
        public void Can_Use_Nested_Builder_With_SetProperty()
        {
            var builder = new BuilderForTesting <ExampleClass>();

            builder.SetProperty <ExampleReferencedClassBuilder>(x => x.ReferenceProp, opts: o => o.WithStringProp("abc"));
            ExampleReferencedClass res = builder.GetProperty(x => x.ReferenceProp, () => null);

            res.Should().NotBeNull("Nested builder should create an instance.");
            res.StringProp.Should().Be("abc", "Nested builder should create an instance with applied opt-ins for the builder.");
        }