I am trying to test this behavior
-- BLOGTableAdapter.GetBlogsByTitle(string title) is called and for once only
-- and is called with string having length greater than 1,
-- and it returns BLOGDataTable Object
[Test]
public void GetBlogsByBlogTitleTest4()
{
var mockAdapter = new Mock<BLOGTableAdapter>();
var mockTable = new Mock<BLOGDataTable>();
mockAdapter.Setup(x => x.GetBlogsByTitle(It.Is<string>(s => s.Length > 0))).Returns(mockTable.Object);
var blogBl = new BlogManagerBLL(mockAdapter.Object);
blogBl.GetBlogsByBlogTitle("Thanks for reading my question");
mockAdapter.VerifyAll();
mockAdapter.Verify(x => x.GetBlogsByTitle(It.Is<string>(s => s.Length > 0)), Times.Exactly(1));
}
When a calls is made to GetBlogsByTitle(string title), in class say "BlogManagerBLL" in Data Aceess Layer
public BLOGDataTable GetBlogsByBlogTitle(string title)
{
return Adapter.GetBlogsByTitle(title);
}
As you can see, I am using two seperate statements to get these checks done
mockAdapter.Setup(x => x.GetBlogsByTitle(It.Is<string>(s => s.Length > 0))).Returns(mockTable.Object);
mockAdapter.Verify(x => x.GetBlogsByTitle(It.Is<string>(s => s.Length > 0)), Times.Exactly(1));
- How can I put this into one statement ?
- Am I testing right things ?
Thanks