public static void Destroy() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); articleService.Delete(_archiveId); } }
public void ArticleService_GetFebNewsIncludingArchive_Got3() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.List(_newsContentId, null, false, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(3)); } }
public void ArticleService_GetFebIdsWithOnlyIds_Got1() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.Ids(0, new [] { 1513, 1514, 1515, _archiveId }, true, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(1)); } }
public void ArticleService_GetFebIds_Got2() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.Ids(_newsContentId, null, true, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(2)); } }
public void ArticleService_GetFebArticlesWithOnlyNullIds_Got0() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.List(0, null, true, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(0)); } }
public void ArticleService_GetFebIdsWithIdsIncludingArchive_Got2() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.Ids(_newsContentId, new [] { 1513, 1514, 1515, _archiveId }, false, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(2)); } }
public void ArticleService_GetFebNews_Got2() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var articles = articleService.List(_newsContentId, null, true, "c.title like '%feb%'").ToArray(); Assert.That(articles.Length, Is.EqualTo(2)); var ra = articles.Single(n => n.Id == 1512).FieldValues.Single(n => n.Field.Name == "Related Articles"); Assert.That(ra.RelatedItems.Length, Is.EqualTo(1)); } }
public static void Init() { using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var article0 = articleService.Read(1512); var copyResult = articleService.Copy(article0); _archiveId = copyResult.Id; articleService.SetArchiveFlag(_newsContentId, new[] { _archiveId }, true); } }
public static void Init() { TestContext.WriteLine($"Using next database for tests: {EnvHelpers.DbNameToRunTests}"); DbConnector = new DBConnector(Global.ConnectionString, Global.ClientDbType) { ForceLocalCache = true }; DictionaryContentId = Global.GetContentId(DbConnector, DictionaryContent); BaseContentId = Global.GetContentId(DbConnector, BaseContent); ArticleService = new ArticleApiService(Global.ConnectionInfo, 1); Clear(); var dbLogService = new Mock <IXmlDbUpdateLogService>(); dbLogService.Setup(m => m.IsFileAlreadyReplayed(It.IsAny <string>())).Returns(false); dbLogService.Setup(m => m.IsActionAlreadyReplayed(It.IsAny <string>())).Returns(false); var service = new XmlDbUpdateNonMvcReplayService( Global.ConnectionString, Global.DbType, null, 1, false, dbLogService.Object, new ApplicationInfoRepository(), new XmlDbUpdateActionCorrecterService( new ArticleService(new ArticleRepository()), new ContentService(new ContentRepository()), new ModelExpressionProvider(new EmptyModelMetadataProvider()) ), new XmlDbUpdateHttpContextProcessor(), Global.Factory.Server.Host.Services, false); service.Process(Global.GetXml($"TestData{Path.DirectorySeparatorChar}batchupdate.xml")); Random = new Random(); DbConnector = new DBConnector(Global.ConnectionString, Global.ClientDbType) { ForceLocalCache = true }; BaseContentId = Global.GetContentId(DbConnector, BaseContent); InitBaseContentFields(); InitExtensions(); DictionaryContentId = Global.GetContentId(DbConnector, DictionaryContent); InitDictionaryContentFields(); }
public void ArticleService_UpdateArticleWithOptimizedHierarchy_UncheckChildren() { var ids = new[] { BaseArticlesIds["root"], BaseArticlesIds["macro1"], BaseArticlesIds["macro2"], BaseArticlesIds["region12"], BaseArticlesIds["district113"] }; var ids2 = new[] { BaseArticlesIds["root"] }; using (new QPConnectionScope(Global.ConnectionInfo)) { var articleService = new ArticleApiService(Global.ConnectionInfo, 1); var article = articleService.New(ProductContentId); article.FieldValues.Single(n => n.Field.Name == "Title").Value = "test"; article.FieldValues.Single(n => n.Field.Name == "Regions").Value = string.Join(",", ids); Assert.DoesNotThrow(() => article = articleService.Save(article), "Create article"); var expected = ids2.OrderBy(n => n).ToArray(); var actual = article.FieldValues.Single(n => n.Field.Name == "Regions").RelatedItems.OrderBy(n => n).ToArray(); Assert.That(actual, Is.EqualTo(expected), "M2M equality"); } }
public static void Init() { TestContext.WriteLine($"Using next database for tests: {Global.DbName}"); DbConnector = new DBConnector(Global.ConnectionString) { ForceLocalCache = true }; DictionaryContentId = Global.GetContentId(DbConnector, DictionaryContent); BaseContentId = Global.GetContentId(DbConnector, BaseContent); ArticleService = new ArticleApiService(Global.ConnectionString, 1); Clear(); var dbLogService = new Mock <IXmlDbUpdateLogService>(); dbLogService.Setup(m => m.IsFileAlreadyReplayed(It.IsAny <string>())).Returns(false); dbLogService.Setup(m => m.IsActionAlreadyReplayed(It.IsAny <string>())).Returns(false); var service = new XmlDbUpdateNonMvcReplayService( Global.ConnectionString, 1, false, dbLogService.Object, new ApplicationInfoRepository(), new XmlDbUpdateActionCorrecterService(new ArticleService(new ArticleRepository()), new ContentService(new ContentRepository())), new XmlDbUpdateHttpContextProcessor(), false ); service.Process(Global.GetXml(@"TestData\batchupdate.xml")); Random = new Random(); BaseContentId = Global.GetContentId(DbConnector, BaseContent); InitBaseContentFields(); InitExtensions(); DictionaryContentId = Global.GetContentId(DbConnector, DictionaryContent); InitDictionaryContentFields(); }