public void LoadDocTypesTest_RecursiveParent()
        {
            ISqlHelper fakeSql = Isolate.Fake.Instance<ISqlHelper>(Members.CallOriginal);

            IRecordsReader reader = Isolate.Fake.Instance<IRecordsReader>();

            Isolate.WhenCalled(() => reader.HasRecords).WillReturnRepeat(true, 3).AndThen().CallOriginal();
            Isolate.WhenCalled(() => reader.Read()).WillReturnRepeat(true, 3).AndThen().CallOriginal();
            Isolate.WhenCalled(() => reader.GetId()).WillReturn(2);
            Isolate.WhenCalled(() => reader.GetParentId()).WillReturn(1);

            Isolate.WhenCalled(() => reader.GetId()).WillReturn(1);
            Isolate.WhenCalled(() => reader.GetParentId()).WillReturn(3);

            Isolate.WhenCalled(() => reader.GetId()).WillReturn(3);
            Isolate.WhenCalled(() => reader.GetParentId()).WillReturn(-1);

            Isolate.WhenCalled(() => fakeSql.ExecuteReader(string.Empty)).WillReturn(reader);

            DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
            Isolate.WhenCalled(() => target.SqlHelper).WillReturn(fakeSql);
            Isolate.WhenCalled(() => target.GetProperties(0)).WillReturn(new System.Collections.Generic.List<DocTypeProperty>());
            Isolate.WhenCalled(() => target.BuildAssociations(0)).WillReturn(new System.Collections.Generic.List<DocTypeAssociation>());

            target.LoadDocTypes();

            Assert.AreEqual(3, target.DocumentTypes.Count);
            Assert.AreEqual(target.DocumentTypes[0].Id, target.DocumentTypes[1].ParentId);

            Isolate.Verify.WasCalledWithExactArguments(() => target.LoadParentDocType(3));
        }
        public void LoadDocTypesTest_ParentNotExists()
        {
            ISqlHelper fakeSql = Isolate.Fake.Instance<ISqlHelper>(Members.CallOriginal);

            IRecordsReader fakeReader = Isolate.Fake.Instance<IRecordsReader>();

            Isolate.WhenCalled(() => fakeReader.HasRecords).WillReturn(true);
            Isolate.WhenCalled(() => fakeReader.HasRecords).CallOriginal();
            Isolate.WhenCalled(() => fakeReader.GetParentId()).WillReturn(1);
            Isolate.WhenCalled(() => fakeReader.Read()).WillReturn(true);
            Isolate.WhenCalled(() => fakeReader.Read()).CallOriginal();

            Isolate.WhenCalled(() => fakeSql.ExecuteReader(string.Empty)).WillReturn(fakeReader);

            DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
            Isolate.WhenCalled(() => target.SqlHelper).WillReturn(fakeSql);

            target.LoadDocTypes();

            Isolate.Verify.WasCalledWithAnyArguments(() => target.LoadParentDocType(1));
        }