public void GetById_ListReturnedIsEmpty_VerifySqlServerDataAccess() { var fakeConfig = MakeFakeConfig(); var stubSqlParameterBuilder = new StubISqlParameterBuilder(); var mockSqlServerDataAccess = new MockISqlServerDataAccess(); var sqlServerAdapter = new BlogPostSqlServerAdapter(fakeConfig, mockSqlServerDataAccess, stubSqlParameterBuilder); var param_id = new BlogPostFactory().Create().PostId; mockSqlServerDataAccess.StubExecuteReaderStoredProcedure(new List <BlogPost>()); sqlServerAdapter.GetById(param_id); mockSqlServerDataAccess.VerifyExecuteReaderStoredProcedureCalled <BlogPost>(1); }
public void GetById_ListReturnedIsEmpty_ReturnsNullBlogPost() { var fakeConfig = MakeFakeConfig(); var stubSqlParameterBuilder = new StubISqlParameterBuilder(); var stubSqlServerDataAccess = new StubISqlServerDataAccess(); var sqlServerAdapter = new BlogPostSqlServerAdapter(fakeConfig, stubSqlServerDataAccess, stubSqlParameterBuilder); var param_id = new BlogPostFactory().Create().PostId; stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(new List <BlogPost>()); var returned_blogpost = sqlServerAdapter.GetById(param_id); Assert.Null(returned_blogpost); }
public void GetById_ListReturnedContainsBlogPost_VerifySqlServerDataAccess() { var fakeConfig = MakeFakeConfig(); var stubSqlParameterBuilder = new StubISqlParameterBuilder(); var mockSqlServerDataAccess = new MockISqlServerDataAccess(); var sqlServerAdapter = new BlogPostSqlServerAdapter(fakeConfig, mockSqlServerDataAccess, stubSqlParameterBuilder); var stub_blogpost = new BlogPostFactory().Create(); var stub_listOfBlogPost = new List <BlogPost> { stub_blogpost }; mockSqlServerDataAccess.StubExecuteReaderStoredProcedure(stub_listOfBlogPost); var param_id = stub_blogpost.PostId; var returned_blogpost = sqlServerAdapter.GetById(param_id); mockSqlServerDataAccess.VerifyExecuteReaderStoredProcedureCalled <BlogPost>(1); }
public void GetById_ListReturnedContainsBlogPost_ReturnsExpectedBlogPost() { var fakeConfig = MakeFakeConfig(); var stubSqlParameterBuilder = new StubISqlParameterBuilder(); var stubSqlServerDataAccess = new StubISqlServerDataAccess(); var sqlServerAdapter = new BlogPostSqlServerAdapter(fakeConfig, stubSqlServerDataAccess, stubSqlParameterBuilder); var expected = new BlogPostFactory().Create(); var stub_listOfBlogPost = new List <BlogPost> { expected }; stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(stub_listOfBlogPost); var param_id = expected.PostId; var actual = sqlServerAdapter.GetById(param_id); Assert.Equal(expected, actual); }