123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System.Collections.Generic;
- using Luticate2.Utils.Dbo.Result;
- using Luticate2.Utils.Utils;
- using WebApiWebSem.DataAccess;
- using WebApiWebSem.Dbo.Articles;
- using WebApiWebSem.Dbo.ArticlesFields;
- using Xunit;
-
- namespace Test.DataAccess
- {
- public class ArticlesDataAccessTest
- {
- [Fact]
- public void Test1()
- {
- Tests.TestRealDb<ArticlesDataAccess>(access =>
- {
- var res = access.AddDbo(new ArticlesAddDbo
- {
- Fields = new List<ArticlesFieldsAddDbo>
- {
- new ArticlesFieldsAddDbo
- {
- Property = "deathDate",
- Type = "date/date",
- Value = "1965-01-24"
- }
- },
- Id = "Winston_Churchill",
- PictureCaption = "Winston Churchill en 1942.",
- PictureUrl = "http://commons.wikimedia.org/wiki/Special:FilePath/Sir_Winston_S_Churchill.jpg?width=300",
- Text = "Winston Churchill, né le 30 novembre 1874 au palais de Blenheim",
- Type = "person"
- });
- Assert.Equal(LuStatus.Success, res.Status);
- Assert.Equal("Winston_Churchill", res.Data.Id);
- });
- }
-
- [Fact]
- public void Test2()
- {
- Tests.TestRealDb<ArticlesDataAccess>(access =>
- {
- var res = access.AddDbo(new ArticlesAddDbo
- {
- Fields = new List<ArticlesFieldsAddDbo>
- {
- new ArticlesFieldsAddDbo
- {
- Property = "deathDate",
- Type = "date/date",
- Value = "1965-01-24"
- }
- },
- Id = "Winston_Churchill",
- PictureCaption = "Winston Churchill en 1942.",
- PictureUrl = "http://commons.wikimedia.org/wiki/Special:FilePath/Sir_Winston_S_Churchill.jpg?width=300",
- Text = "Winston Churchill, né le 30 novembre 1874 au palais de Blenheim",
- Type = "person"
- });
- Assert.Equal(LuStatus.Success, res.Status);
- Assert.Equal("Winston_Churchill", res.Data.Id);
-
- var resGet = access.GetSingleById("Winston_Churchill");
- Assert.Equal(LuStatus.Success, resGet.Status);
- Assert.Equal("Winston_Churchill", resGet.Data.Id);
- Assert.Equal(1, resGet.Data.Fields.Count);
- Assert.Equal("deathDate", resGet.Data.Fields[0].Property);
- });
- }
-
- [Fact]
- public void Test3()
- {
- Tests.TestRealDb<ArticlesDataAccess>(access =>
- {
- var res = access.AddDbo(new ArticlesAddDbo
- {
- Fields = new List<ArticlesFieldsAddDbo>
- {
- new ArticlesFieldsAddDbo
- {
- Property = "deathDate",
- Type = "date/date",
- Value = "1965-01-24"
- }
- },
- Id = "Winston_Churchill",
- PictureCaption = "Winston Churchill en 1942.",
- PictureUrl = "http://commons.wikimedia.org/wiki/Special:FilePath/Sir_Winston_S_Churchill.jpg?width=300",
- Text = "Winston Churchill, né le 30 novembre 1874 au palais de Blenheim",
- Type = "person"
- });
- Assert.Equal(LuStatus.Success, res.Status);
- Assert.Equal("Winston_Churchill", res.Data.Id);
-
-
- var resEdit = access.EditSingleByIdDbo("Winston_Churchill", new ArticlesEditDbo
- {
- Fields = new List<ArticlesFieldsEditDbo>
- {
- new ArticlesFieldsAddDbo
- {
- Property = "deathDate",
- Type = "date/date",
- Value = "1965-01-25"
- }
- },
- PictureCaption = "Test.",
- PictureUrl = "http://commons.wikimedia.org/wiki/Special:FilePath/Sir_Winston_S_Churchill.jpg?width=300",
- Text = "Winston Churchill, né le 30 novembre 1874 au palais de Blenheim"
- });
- Assert.Equal(null, resEdit.Exception);
- Assert.Equal(LuStatus.Success, resEdit.Status);
- Assert.Equal("Winston_Churchill", resEdit.Data.Id);
- Assert.Equal("Test.", resEdit.Data.PictureCaption);
- Assert.Equal(1, resEdit.Data.Fields.Count);
- Assert.Equal("deathDate", resEdit.Data.Fields[0].Property);
- Assert.Equal("1965-01-25", resEdit.Data.Fields[0].Value);
-
-
-
- var resGet = access.GetSingleById("Winston_Churchill");
- Assert.Equal(LuStatus.Success, resGet.Status);
- Assert.Equal("Winston_Churchill", resGet.Data.Id);
- Assert.Equal(1, resGet.Data.Fields.Count);
- Assert.Equal("deathDate", resGet.Data.Fields[0].Property);
- Assert.Equal("1965-01-25", resGet.Data.Fields[0].Value);
- });
- }
- }
- }
|