public async Task AddNewMetadataTest() { var author = ServiceProvider.GetService <IBlogAuthor>(); var metadata = await author.GetMetadata(); var objTag = new MetadataItem { Versions = new[] { new MetadataVersion { Slug = "tips", Type = MetadataType.Tag, LanguageCode = "en", Name = "Tips" } } }; metadata.Items = metadata.Items.Add(objTag); await author.UpdateMetadata(metadata); var dbMetadata = await author.GetMetadata(); Assert.AreEqual(metadata.Items.Length, dbMetadata.Items.Length); for (int i = 0; i < metadata.Items.Length; i++) { for (int j = 0; j < metadata.Items[i].Versions.Length; j++) { Assert.IsTrue(MemberCompare.Equal(metadata.Items[i].Versions[j], dbMetadata.Items[i].Versions[j])); } } }
public async Task CreateArticleTest() { var author = ServiceProvider.GetService <IBlogAuthor>(); var article = this.GenerateArticle(); await author.CreateArticle(article); var result = await author.GetArticles("john-smith"); var dbArticle = result.First(); Assert.AreEqual("article.00001", dbArticle.Id); Assert.AreEqual(article.State, dbArticle.State); Assert.AreEqual(article.Created, dbArticle.Created); Assert.AreEqual(article.Name, dbArticle.Name); for (int i = 0; i < article.Versions.Length; i++) { Assert.AreEqual(article.Versions[i].ArticleId, dbArticle.Versions[i].ArticleId); Assert.AreEqual(article.Versions[i].Body, dbArticle.Versions[i].Body); Assert.AreEqual(article.Versions[i].LanguageCode, dbArticle.Versions[i].LanguageCode); Assert.AreEqual(article.Versions[i].Slug, dbArticle.Versions[i].Slug); Assert.AreEqual(article.Versions[i].Summary, dbArticle.Versions[i].Summary); Assert.AreEqual(article.Versions[i].Title, dbArticle.Versions[i].Title); } Assert.IsTrue(MemberCompare.Equal(article.Versions[0].Metadata[0], article.Versions[0].Metadata[0])); Assert.IsTrue(MemberCompare.Equal(article.Versions[0].Metadata[1], article.Versions[0].Metadata[1])); Assert.IsTrue(MemberCompare.Equal(article.Versions[1].Metadata[0], article.Versions[1].Metadata[0])); Assert.IsTrue(MemberCompare.Equal(article.Versions[1].Metadata[1], article.Versions[1].Metadata[1])); Assert.IsTrue(MemberCompare.Equal(article.Versions[0].Author, article.Versions[0].Author)); }
public async Task GetMetadataTest() { var author = ServiceProvider.GetService <IBlogAuthor>(); var metadata = await author.GetMetadata(); metadata.Items = metadata.Items.Add(new MetadataItem { Versions = new [] { new MetadataVersion { LanguageCode = "en", Name = "English Category", Slug = "english-category", Type = MetadataType.Category }, new MetadataVersion { LanguageCode = "cs", Name = "Czech Category", Slug = "czech-category", Type = MetadataType.Category } } }); metadata.Items = metadata.Items.Add(new MetadataItem { Versions = new[] { new MetadataVersion { LanguageCode = "en", Name = "English Tag", Slug = "english-tag", Type = MetadataType.Tag }, new MetadataVersion { LanguageCode = "cs", Name = "Czech Tag", Slug = "czech-tag", Type = MetadataType.Tag } } }); await author.UpdateMetadata(metadata); var reader = ServiceProvider.GetService <IBlogReader>(); MetadataVersion[] versions = await reader.GetMetadata("cs"); Assert.AreEqual(2, versions.Length); Assert.IsTrue(MemberCompare.Equal(metadata.Items[0].Versions[1], versions[0])); Assert.IsTrue(MemberCompare.Equal(metadata.Items[1].Versions[1], versions[1])); }
public async Task GetArticleReturnsSpecifiedArticle() { var author = ServiceProvider.GetService <IBlogAuthor>(); var reader = ServiceProvider.GetService <IBlogReader>(); var article = this.GenerateArticle(); await author.CreateArticle(article); var memArticle = article.Versions.First(); var dbArticle = await reader.GetArticle(memArticle.Slug, memArticle.LanguageCode); Assert.AreEqual(memArticle.Title, dbArticle.Title); Assert.AreEqual(memArticle.Summary, dbArticle.Summary); Assert.AreEqual(memArticle.Body, dbArticle.Body); Assert.AreEqual(memArticle.Slug, dbArticle.Slug); Assert.AreEqual(memArticle.LanguageCode, dbArticle.LanguageCode); Assert.AreEqual(memArticle.Metadata.Length, dbArticle.Metadata.Length); for (var i = 0; i < memArticle.Metadata.Length; i++) { Assert.IsTrue(MemberCompare.Equal(memArticle.Metadata[i], dbArticle.Metadata[i])); } }
public Boolean Equals(L7Pdu x, L7Pdu y) => MemberCompare.Equal(x, y);