|
|
|
@ -30,7 +30,7 @@ public class TestParagraphDataService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
public void GetParagraphs_WithoutCriteria_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
@ -59,6 +59,223 @@ public class TestParagraphDataService
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_OrderdByTitle_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, 2, ParagraphOrderCriteria.ByTitle);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_OrderedByContent_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, 2, ParagraphOrderCriteria.ByContent);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_OrderedByQuery_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, 2, ParagraphOrderCriteria.ByQuery);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_OrderedByInfo_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, 2, ParagraphOrderCriteria.ByInfo);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_OrderedByComment_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, 2, ParagraphOrderCriteria.ByComment);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_WithBadPage_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(-42, 2, ParagraphOrderCriteria.None);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphs_WithBadNumber_ReturnsCorrectNumberOfParagraphs()
|
|
|
|
|
{
|
|
|
|
|
_dbContext.Lessons.Add(_lesson);
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 1, ContentContent = "ContentContent1", ContentTitle = "ContentTitle1", Title = "Test1",
|
|
|
|
|
Content = "Content1", Info = "Info1", Query = "Query1", Comment = "Comment1",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 2, ContentContent = "ContentContent2", ContentTitle = "ContentTitl2", Title = "Test2",
|
|
|
|
|
Content = "Content2", Info = "Info2", Query = "Query2", Comment = "Comment2",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.Paragraphs.Add(new ParagraphEntity
|
|
|
|
|
{
|
|
|
|
|
Id = 3, ContentContent = "ContentContent3", ContentTitle = "ContentTitle3", Title = "Test3",
|
|
|
|
|
Content = "Content3", Info = "Info3", Query = "Query3", Comment = "Comment3",
|
|
|
|
|
LessonId = 1
|
|
|
|
|
});
|
|
|
|
|
_dbContext.SaveChanges();
|
|
|
|
|
|
|
|
|
|
var result = _paragraphDataService.GetParagraphs(1, -42, ParagraphOrderCriteria.None);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(3, result.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetParagraphById_ReturnsCorrectParagraph()
|
|
|
|
|