ModelBuilder.UnitTests.ScenarioTests.CreateThrowsExceptionWhenPropertyCannotBeCreatedTest C# (CSharp) Method

CreateThrowsExceptionWhenPropertyCannotBeCreatedTest() private method

        public void CreateThrowsExceptionWhenPropertyCannotBeCreatedTest()
        {
            var typeCreator = Substitute.For<ITypeCreator>();

            typeCreator.CanCreate(typeof(Address), "Address", Arg.Any<LinkedList<object>>()).Returns(true);
            typeCreator.Priority.Returns(int.MaxValue);
            typeCreator.AutoDetectConstructor.Returns(true);
            typeCreator.AutoPopulate.Returns(true);
            typeCreator.Create(typeof(Address), "Address", Arg.Any<LinkedList<object>>())
                .Throws(new InvalidOperationException());

            var buildStrategy = new DefaultBuildStrategyCompiler().Add(typeCreator).Compile();

            var target = new DefaultExecuteStrategy<Company>();

            target.Initialize(buildStrategy, buildStrategy.GetBuildLog());

            Action action = () => target.CreateWith();

            var exception =
                action.ShouldThrow<BuildException>().Where(x => x.Message != null).Where(x => x.BuildLog != null).Which;

            _output.WriteLine(exception.Message);
        }