public TestDataGeneratorClassFillingSpeck() { Specify(x => TestDataGenerator.Create <Universe> (MaxRecursionDepth, null)) .Case("should fill normal property deep in hierarchy", _ => _ .Given(SimpleStringContext(3)) .It("fills properties in 1st level deep hierarchy", x => x.Result.Galaxy1.StarSystem1.Planet1.President.Name.Should().Be("SomeString")) .It("fill properties in 2nd level deep hierarchy", x => x.Result.Galaxy1.StarSystem1.Planet1.President.Atom1.Particle1.QuantumUniverse.Galaxy1.StarSystem1.Planet1.President.Name.Should() .Be("SomeString")) .It("aborts hierarchy filling at 3rd level top element (QuantumUniverse)", x => x.Result.Galaxy1.StarSystem1.Planet1.President.Atom1.Particle1.QuantumUniverse.Galaxy1.StarSystem1.Planet1.President.Atom1.Particle1 .QuantumUniverse.Galaxy1.Should() .BeNull())); Specify(x => TestDataGenerator.Create <LandVehicle> (MaxRecursionDepth, null)) .Case("should fill properties according to provider chain1", _ => _ .Given(PropertyProviderContext()) .It("should fill weight", x => x.Result.Weight.Should().Be(100)) .It("should fill main color", x => x.Result.MainColor.Should().Be(Color.Red)) .It("should fill tire diameter", x => x.Result.Tire.Diameter.Should().Be(3.6)) .It("should fill grip", x => x.Result.Tire.Grip.Should().Be(3.6))); Specify(x => TestDataGenerator.Create <AirVehicle> (MaxRecursionDepth, null)) .Case("should fill properties according to provider chain2", _ => _ .Given(PropertyProviderContext()) .It("should fill weight as specified", x => x.Result.Weight.Should().Be(5)) .It("should fill main color as specified", x => x.Result.MainColor.Should().Be(Color.Green)) .It("should fill engine with jetengine", x => x.Result.Engine.Should().BeOfType(typeof(JetEngine))) .It("should fill fuel use per second as specified", x => ((JetEngine)x.Result.Engine).FuelUsePerSecond.Should().Be(1.1f)) .It("should fill powerinnewtons as specified", x => x.Result.Engine.PowerInNewtons.Should().Be(5000f))); Specify(x => TestDataGenerator.Create <AirVehicle> (MaxRecursionDepth, null)) .Case("throws for abstract properties because of default provider chain", _ => _ .Given(BaseDomainContext()) .ItThrows(typeof(NotSupportedException), "Could not auto-fill AirVehicle (member Engine). Please provide a value provider") .ItThrowsInner(typeof(NotSupportedException), "No valid ctor found on 'Engine': Classes with non-public constructors and abstract classes are not supported.")); Specify(x => TestDataGenerator.Create <LandVehicle> (MaxRecursionDepth, null)) .Case("should fill properties according to provider chain3", _ => _ .Given(HierarchyPropertyProviderContext()) // //test simple cases again because of more complex domain .It("should fill weight as specified", x => x.Result.Weight.Should().Be(50)) .It("should fill main color as specified", x => x.Result.MainColor.Should().Be(Color.Black)) .It("should fill tire diameter as specified", x => x.Result.Tire.Diameter.Should().Be(1.2)) .It("should fill grip as specified", x => x.Result.Tire.Grip.Should().Be(1.2))); Specify(x => TestDataGenerator.CreateMany <AirVehicle> (2, MaxRecursionDepth, null).First()) .Case("should fill properties according to provider chain4", _ => _ .Given(HierarchyPropertyProviderContext()) // //test simple cases again because of more complex domain .It("should fill weight as specified", x => x.Result.Weight.Should().Be(50)) .It("should fill main color as specified", x => x.Result.MainColor.Should().Be(Color.Black)) //start testing concrete domain logic .It("should fill engine with PropellorEngine", x => x.Result.Engine.Should().BeOfType(typeof(PropellorEngine))) .It("should fill fuel use per second as specified", x => ((PropellorEngine)x.Result.Engine).AverageRotationSpeed.Should().Be(2.1f)) .It("should fill PowerInNewtons as specified", x => x.Result.Engine.PowerInNewtons.Should().Be(250f))); Specify(x => TestDataGenerator.CreateMany <AirVehicle> (2, MaxRecursionDepth, null).Last()) .Case("should fill properties according to provider chain5", _ => _ .Given(HierarchyPropertyProviderContext()) // //test simple cases again because of more complex domain .It("should fill weight as specified", x => x.Result.Weight.Should().Be(50)) .It("should fill main color as specified", x => x.Result.MainColor.Should().Be(Color.Black)) //start testing concrete domain logic .It("should fill engine with jetengine", x => x.Result.Engine.Should().BeOfType(typeof(JetEngine))) .It("should fill fuel use per second as specified", x => ((JetEngine)x.Result.Engine).FuelUsePerSecond.Should().Be(2.1f)) .It("should fill powerinnewtons as specified", x => x.Result.Engine.PowerInNewtons.Should().Be(1200))); Specify(x => TestDataGenerator.Create <LandVehicle> (MaxRecursionDepth, null)) .Case("should fill properties according to provider chain6", _ => _ .Given(AttributeProviderContext()) .It("should fill tire usage", x => x.Result.Tire.TireUsage.Should().Be(100.1d)) .It("should fill weight", x => x.Result.Weight.Should().Be(52))); Specify(x => TestDataGenerator.Create <LandVehicle> (MaxRecursionDepth, null)) .Case("should fill properties according to provider chain7", _ => _ .Given(TypeHierarchyChainProviderContext()) .It("should fill name", x => x.Result.Name.Should().Be("12345!6!78"))); Specify(x => TestDataGenerator.Create <ClassWithMixedMembers> (MaxRecursionDepth, null)) .Case("should fill mixed properties correctly", _ => _ .Given(BaseDomainContext(seed: 0)) .It("should fill public property", x => x.Result.PublicProperty.Should().Be("Vigimuhe")) .It("should fill public field", x => x.Result.PublicField.Should().Be("Zaxsewu")) .It("Should not fill private property", x => x.Result.GetPrivateProperty().Should().Be("default")) .It("Should not fill private field", x => x.Result.GetPrivateField().Should().Be("default"))); }