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"); } } } } }
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)); }
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)); } }
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); } }
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)); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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)); } }
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); }
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); } }
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); }
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))); } }
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)); } }
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)); } }
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)); } }
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); } }
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)); } } }
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); } }
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("//")); } } }
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))); } }
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(); } }
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); }
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(); } }
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(); } }
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); } }