Esempio n. 1
0
 public void Collection_Is_Set_With_Valid_Number_In_It()
 {
     for (int x = 0; x < 10; x++)
     {
         var node = mSession.Next <SimpleNode>();
         Assert.True(node.Children.Count >= 0 && node.Children.Count <= 3);
     }
 }
        public void With_No_Config_Least_Greedy_Constructor_With_Default_Conventions_Is_Used_By_Default()
        {
            mSession = AutoPocoContainer.CreateDefaultSession();

            var result = mSession.Next <SimpleCtorClass>();

            Assert.NotNull(result.ReadOnlyProperty);
            Assert.Null(result.SecondaryProperty);
        }
        public void With_Source_Source_Is_Used_To_Create_Object()
        {
            mSession = AutoPocoContainer.Configure(x => x.Include <SimpleCtorClass>()
                                                   .ConstructWith <TestFactory>()).CreateSession();

            var result = mSession.Next <SimpleCtorClass>();

            Assert.AreEqual("one", result.ReadOnlyProperty);
            Assert.AreEqual("two", result.SecondaryProperty);
        }
        public void Property_Is_Set_With_Parent_Value_If_Parent_Exists()
        {
            IGenerationSession session = AutoPocoContainer.Configure(
                x => x.Include <SimpleNode>()
                .Setup(y => y.Children).Collection(1, 1)
                .Setup(y => y.Parent).Use <ParentSource <SimpleNode> >()).CreateSession();

            var node = session.Next <SimpleNode>();

            Assert.AreEqual(node, node.Children.First().Parent);
        }
        public void Property_Is_Set_With_Null_Value_If_No_Parent_Exists()
        {
            IGenerationSession session = AutoPocoContainer.Configure(
                x =>
            {
                x.Include <SimpleNode>().Setup(y => y.Children).Collection(1, 1);
            }).CreateSession();

            var node = session.Next <SimpleNode>();

            Assert.Null(node.Parent);
        }
        public void Requesting_Recursive_Type_Honours_Length_Limit()
        {
            var node = mSession.Next <SimpleNode>();
            int x    = 0;

            while (node != null)
            {
                node = node.Parent;
                x++;

                if (x > 10)
                {
                    Assert.Fail("Recursive limit was not honoured"); break;
                }
            }
        }
        public void Property_Is_Set_With_Null_Value_If_No_Parent_Exists()
        {
            var node = mSession.Next <SimpleNode>();

            Assert.Null(node.Parent);
        }