public void GetSelectedObjects_ReturnsObjectsByGivenIdentifiersAndObjectType(string objectType, IEnumerable <string> selectIdentifiers, bool useGuid, Type expectedType)
            {
                var objectsRetriever  = new ObjectsRetriever(siteService);
                var result            = objectsRetriever.GetSelectedObjects(objectType, selectIdentifiers, useGuid);
                var actualIdentifiers = result
                                        .ToArray()
                                        .Select(info => useGuid ? info[info.TypeInfo.GUIDColumn] : info[info.TypeInfo.CodeNameColumn])
                                        .Select(id => id.ToString());

                Assert.That(actualIdentifiers, Is.EquivalentTo(selectIdentifiers));
                Assert.That(result, Is.All.TypeOf(expectedType));
            }
            public void GetObjectQuery_ReturnsCorrectResult(string objectType, bool hasCodeName, string[] expectedIdentifiers)
            {
                var    typeInfo         = ObjectTypeManager.GetTypeInfo(objectType);
                var    retriever        = new ObjectsRetriever(siteService);
                var    query            = retriever.GetObjectsQuery(objectType);
                string identifierColumn = hasCodeName ? typeInfo.CodeNameColumn : typeInfo.GUIDColumn;

                var result      = query.ToArray();
                var actualNames = result.Select(o => o[identifierColumn].ToString());

                Assert.That(actualNames, Is.EquivalentTo(expectedIdentifiers));
                Assert.That(result.All(o => !String.IsNullOrEmpty(o[typeInfo.DisplayNameColumn].ToString())), Is.True);
            }
            public void SetUp()
            {
                Fake <ContactGroupMemberInfo, ContactGroupMemberInfoProvider>();
                contactClassStructureInfo = new InternalsVisibleFakeClassStructure <ContactInfo>();
                var contactProviderFake = Fake <ContactInfo, ContactInfoProvider>().WithOriginalSourceName();
                var contacts            = CreateItems <ContactInfo>(new[] { "Test", "Foo", "Bar" }, 7);

                contactProviderFake.WithData(contacts);

                userClassStructureInfo = new InternalsVisibleFakeClassStructure <UserInfo>();
                var userProviderFake = Fake <UserInfo, UserInfoProvider>().WithOriginalSourceName();
                var users            = CreateItems <UserInfo>(new[] { "John", "Paul", "Ringo", "George" }, 15);

                userProviderFake.WithData(users);

                UserInfo.TYPEINFO.ClassStructureInfo    = userClassStructureInfo;
                ContactInfo.TYPEINFO.ClassStructureInfo = contactClassStructureInfo;
                objectsRetriever = new ObjectsRetriever(Substitute.For <ISiteService>());
            }
Пример #4
0
 internal KenticoObjectSelectorController(ObjectsRetriever objectsRetriever)
 {
     this.objectsRetriever = objectsRetriever;
 }
            public void GetSelectedObjects_ThrowsException(string objectType, bool useGuid)
            {
                var objectsRetriever = new ObjectsRetriever(siteService);

                Assert.That(() => objectsRetriever.GetSelectedObjects(objectType, Enumerable.Empty <string>(), useGuid), Throws.InvalidOperationException);
            }