public void Nested_Lambda_Is_Merged_With_Default_Lambdas() { var builder = new ExampleClassBuilder() .WithReferenceProp(x => x.WithDateTimeProp(DateTime.Now)); ExampleClass res = builder.Create(); res.ReferenceProp.StringProp.Should().Be("I am default"); }
public void Nested_Lambda_Is_Applied_On_Nested_Builder() { var builder = new ExampleClassBuilder() .WithReferenceProp(x => x.WithStringProp("I am child")); ExampleClass res = builder.Create(); res.ReferenceProp.StringProp.Should().Be("I am child"); }
public void Setup_Is_Applied_On_Create() { var builder = new ExampleClassBuilder(); builder.Setup(x => x.WithStringProp("Foo")); ExampleClass res = builder.Create(); res.StringProp.Should().Be("Foo"); }
public void Setup_Overrides_On_Create() { var builder = new ExampleClassBuilder() .WithStringProp("Foo"); builder.Setup(x => x.WithStringProp("Bar")); var res = builder.Create(); res.StringProp.Should().Be("Bar"); }
public void Nested_Lambda_With_Instance_Uses_The_Instance() { var something = "I am from instance"; var someDate = DateTime.Now.AddDays(-1); var exampleReferencedClass = new ExampleReferencedClassBuilder().WithDateTimeProp(someDate).WithStringProp(something).Create(); var builder = new ExampleClassBuilder() .WithReferenceProp(x => x.WithInstance(exampleReferencedClass)); var res = builder.Create(); res.ReferenceProp.StringProp.Should().Be(something); res.ReferenceProp.DateProp.Should().Be(someDate); }