コード例 #1
0
 public void Check_That_BackSymmetric_Relation_Field_isLoaded([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.SymmetricRelationArticles.Include(x => x.SymmetricRelation.Select(y => y.ToSymmetricRelation)).FirstOrDefault();
         if (items.SymmetricRelation.Count == 0)
         {
             Assert.Fail("SymmerticRelation field not filled");
         }
         else
         {
             foreach (var item in items.SymmetricRelation)
             {
                 if (item.ToSymmetricRelation.Count > 0)
                 {
                     var ids = item.ToSymmetricRelation.Select(s => s.Id).ToList();
                     if (!ids.Contains(items.Id))
                     {
                         Assert.Fail("SymmerticRelation field not filled");
                     }
                 }
                 else
                 {
                     Assert.Fail("SymmerticRelation field not filled");
                 }
             }
         }
     }
 }
コード例 #2
0
        public static EF6Model CreateWithStaticMapping(ContentAccess contentAccess, SqlConnection connection, bool contextOwnsConnection)
        {
            var schemaProvider = new StaticSchemaProvider();
            var configurator   = new MappingConfigurator(contentAccess, schemaProvider);

            return(Create(configurator, connection, contextOwnsConnection));
        }
コード例 #3
0
 public void Check_That_Splitted_Article_isLoaded_Published_Version([Values(ContentAccess.Live)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var item = context.PublishedNotPublishedItems.Where(x => x.Alias.Equals(ALIAS_FOR_SPLITTED_ARTICLES)).FirstOrDefault();
         Assert.That(item.Title, Is.EqualTo(TITLE_FOR_SPLITTED_PPUBLISHED_ARTICLES));
     }
 }
コード例 #4
0
 public void Check_That_inVisible_Article_isLoaded([Values(ContentAccess.StageNoDefaultFiltration)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var item = context.PublishedNotPublishedItems.Where(x => !x.Visible).ToArray();
         Assert.That(item, Is.Not.Null.Or.Empty);
     }
 }
コード例 #5
0
 public void Check_That_Symmetric_Relation_Field_isLoaded([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.SymmetricRelationArticles.Include(x => x.SymmetricRelation).FirstOrDefault();
         Assert.That(items.SymmetricRelation.Count, Is.Not.EqualTo(0));
     }
 }
コード例 #6
0
 public void Check_That_Invisible_Article_notLoaded([Values(ContentAccess.Live)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var inVisibleItems = context.PublishedNotPublishedItems.Where(x => !x.Visible).ToArray();
         Assert.That(inVisibleItems, Is.Null.Or.Empty);
     }
 }
コード例 #7
0
 public void DataContext_UserGroups_Read([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var groups = context.UserGroups.Include(g => g.Users).ToArray();
         Assert.That(groups, Is.Not.Null.And.Not.Empty);
     }
 }
コード例 #8
0
 public void DataContext_StatusTypes_Read([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var statusTypes = context.StatusTypes.ToArray();
         Assert.That(statusTypes, Is.Not.Null.And.Not.Empty);
     }
 }
コード例 #9
0
 public void Check_That_Published_Article_isLoaded([Values(ContentAccess.Live)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.PublishedNotPublishedItems.ToArray();
         Assert.That(items, Is.Not.Null.And.Not.Empty);
     }
 }
コード例 #10
0
 public void Check_That_Field_FileFieldUploadPath_isGenerated([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.FileFieldsItems.FirstOrDefault();
         Assert.That(items.FileItemUploadPath, Is.Not.Null);
     }
 }
コード例 #11
0
 public void Check_That_nonPublished_Article_isLoaded([Values(ContentAccess.StageNoDefaultFiltration)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var status = ValuesHelper.GetNonPublishedStatus(mapping);
         var items  = context.PublishedNotPublishedItems.Where(x => x.StatusTypeId == status).ToArray();
         Assert.That(items, Is.Not.Null.And.Not.Empty);
     }
 }
コード例 #12
0
 public void Check_That_o2m_Relation_Field_toNotMapped_IsLoaded([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var item = context.OtMItemsToContentWithoutMapping.FirstOrDefault();
         Assert.That(item, Is.Not.Null);
         Assert.That(item.OtMReferenceMapping_ID, Is.Not.Null);
     }
 }
コード例 #13
0
 public void Check_That_FileFieldUploadPath_isCorrect_Fill([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.FileFieldsItems.FirstOrDefault();
         var expectedUploadPath = UPLOAD_PATH + ValuesHelper.GetFileContentId(mapping);
         Assert.That(items.FileItemUploadPath, Is.EqualTo(expectedUploadPath));
     }
 }
コード例 #14
0
        public static QpDataContext CreateWithDatabaseMapping(ContentAccess contentAccess, string siteName, DbConnection connection)
        {
            var schemaProvider = new DatabaseSchemaProvider(siteName, connection);
            var configurator   = new MappingConfigurator(contentAccess, schemaProvider);
            var context        = Create(configurator, connection);

            context.SiteName = siteName;
            return(context);
        }
コード例 #15
0
 public void Check_That_nonPublished_Article_notLoaded([Values(ContentAccess.Live)] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var status            = ValuesHelper.GetNonPublishedStatus(mapping);
         var nonpublishedItems = context.PublishedNotPublishedItems.Where(x => x.StatusTypeId == status).ToArray();
         Assert.That(nonpublishedItems, Is.Null.Or.Empty);
     }
 }
コード例 #16
0
        public static EF6Model CreateWithDatabaseMapping(ContentAccess contentAccess, string siteName, SqlConnection connection, bool contextOwnsConnection)
        {
            var schemaProvider = new DatabaseSchemaProvider(siteName, connection);
            var configurator   = new MappingConfigurator(contentAccess, schemaProvider);
            var context        = Create(configurator, connection, contextOwnsConnection);

            context.SiteName = siteName;
            return(context);
        }
コード例 #17
0
 public void Check_That_StringItem_StringValue_NotEmpty([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.StringItems.ToArray();
         Assert.That(items, Is.Not.Null.And.Not.Empty);
         Assert.That(items, Is.All.Matches <StringItem>(itm => !string.IsNullOrEmpty(itm.StringValue)));
     }
 }
コード例 #18
0
        public void DataContext_Schema_GetContentInfo([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var contentId         = context.GetInfo <Schema>().Id;
                int expectedContentId = ValuesHelper.GetSchemaContentId(mapping);

                Assert.That(contentId, Is.EqualTo(expectedContentId));
            }
        }
コード例 #19
0
 public void Check_That_FileFieldUrl_isCorrect_Fill([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var items = context.FileFieldsItems.FirstOrDefault();
         var pref  = context.Cnn.GetUploadUrlPrefix(context.SiteId);
         var url   = ExpectedUploadUrl(pref, items.FileItem, mapping);
         Assert.That(items.FileItemUrl, Is.EqualTo(url));
     }
 }
コード例 #20
0
        public void DataContext_Schema_GetAttributeInfo([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var attributeId         = context.GetInfo <Schema>(a => a.Title).Id;
                var expectedattributeId = ValuesHelper.GetSchemaTitleFieldId(mapping);

                Assert.That(attributeId, Is.EqualTo(expectedattributeId));
            }
        }
コード例 #21
0
 public void Check_That_o2m_Relation_Field_toMapped_IsLoaded([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var item    = context.OtMItemsForMapping.FirstOrDefault();
         var related = context.OtMRelatedItemsWithMapping.FirstOrDefault();
         Assert.That(item, Is.Not.Null);
         Assert.That(related, Is.Not.Null);
         Assert.AreEqual(item.OtMReferenceMapping_ID, related.Id);
         Assert.AreEqual(item.OtMReferenceMapping.Id, related.Id);
     }
 }
コード例 #22
0
 public void Check_Replacing_Placeholder_IF_False([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         bool ReplaceUrls = GetValueReplaceUrl(context, mapping);
         if (!ReplaceUrls)
         {
             var   item  = context.ReplacingPlaceholdersItems.FirstOrDefault();
             Match match = URL_PLACEHOLDER.Match(item.Title);
             Assert.That(match.Length, Is.Not.EqualTo(0));
         }
     }
 }
コード例 #23
0
        public void Check_That_Article_IsDeleted([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var item = context.ItemsForInsert.FirstOrDefault();
                Assert.That(item, Is.Not.Null);

                context.ItemsForInsert.Remove(item);
                context.SaveChanges();

                var deletedItem = context.ItemsForInsert.FirstOrDefault(itm => itm.Id == item.Id);
                Assert.That(deletedItem, Is.Null);
            }
        }
コード例 #24
0
 public void Check_That_FileFieldUrl_Changed([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
 {
     using (var context = GetDataContext(access, mapping))
     {
         var pref  = context.Cnn.GetUploadUrlPrefix(context.SiteId);
         var items = context.FileFieldsItems.FirstOrDefault();
         if (string.IsNullOrEmpty(pref))
         {
             Assert.That(items.FileItemUrl, Does.StartWith("/upload"));
         }
         else
         {
             Assert.That(items.FileItemUrl, Does.StartWith("http").Or.StartWith("//"));
         }
     }
 }
コード例 #25
0
        protected void UpdateProperty <TArticle>(ContentAccess access, Mapping mapping, Action <TArticle> setField, Func <TArticle, object> getField)
            where TArticle : class
        {
            using (var context = GetDataContext(access, mapping))
            {
                var oldItem = context.Set <TArticle>().FirstOrDefault();
                Assert.That(oldItem, Is.Not.Null);

                setField(oldItem);
                context.SaveChanges();

                var newItem = context.Set <TArticle>().FirstOrDefault();
                Assert.That(newItem, Is.Not.Null);

                Assert.That(getField(newItem), Is.EqualTo(getField(oldItem)));
            }
        }
コード例 #26
0
        public void Check_That_OtM_Field_isUpdated([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var items = context.OtMItemsForUpdate.Take(5).ToArray();
                var dict  = context.OtMDictionaryForUpdate.FirstOrDefault();
                Assert.That(dict, Is.Not.Null);

                foreach (var item in items)
                {
                    item.Title     = $"{nameof(Check_That_OtM_Field_isUpdated)}_{Guid.NewGuid()}";
                    item.Reference = dict;
                }

                context.SaveChanges();
            }
        }
コード例 #27
0
        public static XElement Construct(IEnumerable <Item> itemInput, string publisher)
        {
            var result = new XElement("itempool");

            result.Add(ExtractionSettings.ItemInput.Select(
                           x => new { Content = ContentAccess.RetrieveDocument($"Item-{x.ItemId}"), x.ItemId })
                       .Select(
                           x =>
                           TestItem.Construct(x.Content,
                                              ItemStimuliMapper.Map(x.Content, itemInput.First(y => y.ItemId.Equals(x.ItemId))), publisher)));
            result.Add(itemInput
                       .Where(x => !string.IsNullOrEmpty(x.AssociatedStimuliId)).Select(x => x.AssociatedStimuliId)
                       .Distinct()
                       .Select(x => new XElement("passage",
                                                 new XAttribute("filename", $"stim-{x}.xml"),
                                                 Identifier.Construct(x, "1"))));
            return(result);
        }
コード例 #28
0
        public void Check_That_OtM_Field_isCreated([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var item = new OtMItemForUpdate()
                {
                    Title = $"{nameof(Check_That_OtM_Field_isCreated)}_{Guid.NewGuid()}"
                };
                var dict = context.OtMDictionaryForUpdate.FirstOrDefault();

                Assert.That(dict, Is.Not.Null);

                item.Reference = dict;

                context.OtMItemsForUpdate.Add(item);
                context.SaveChanges();
            }
        }
コード例 #29
0
        public void Check_That_MtM_Field_isUpdated([ContentAccessValues] ContentAccess access, [MappingValues] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var items = context.MtMItemsForUpdate.ToArray();
                var dict  = context.MtMDictionaryForUpdate.Take(2).ToArray();

                foreach (var item in items)
                {
                    item.Title = $"{nameof(Check_That_MtM_Field_isUpdated)}_{Guid.NewGuid()}";

                    foreach (var d in dict)
                    {
                        item.Reference.Add(d);
                    }
                }

                context.SaveChanges();
            }
        }
コード例 #30
0
        public void DataContext_AfiellFieldsItems_Insert([Values(ContentAccess.Stage)] ContentAccess access, [Values(Mapping.StaticMapping)] Mapping mapping)
        {
            using (var context = GetDataContext(access, mapping))
            {
                var article = new AfiellFieldsItem()
                {
                    String   = "str",
                    TextBox  = "tbx",
                    DateTime = DateTime.Now,
                    Image    = "users.gif",
                    Integer  = 90,
                    Created  = DateTime.Today
                };

                context.AfiellFieldsItems.Add(article);
                context.SaveChanges();

                Assert.That(article.Id, Is.Not.EqualTo(0));
                Assert.That(context.AfiellFieldsItems.Any(a => a.Id == article.Id), Is.True);
            }
        }