public void GetById_ListReturnedIsEmpty_VerifySqlParameterBuilder()
        {
            var fakeConfig = MakeFakeConfig();
            var mockSqlParameterBuilder = new MockISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogUserSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, mockSqlParameterBuilder);
            var param_id = new BlogUserFactory().Create().UserId;

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(new List <BlogUser>());

            sqlServerAdapter.GetById(param_id);

            mockSqlParameterBuilder.VerifyBuildSqlParameterCalled <BlogUser>(1);
        }
        public void GetById_ListReturnedIsEmpty_ReturnsNullBlogUser()
        {
            var fakeConfig = MakeFakeConfig();
            var stubSqlParameterBuilder = new StubISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogUserSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, stubSqlParameterBuilder);
            var param_id = new BlogUserFactory().Create().UserId;

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(new List <BlogUser>());

            var returned_blogpost = sqlServerAdapter.GetById(param_id);

            Assert.Null(returned_blogpost);
        }
        public void List_ReturnsExpectedList()
        {
            var fakeConfig = MakeFakeConfig();
            var stubSqlParameterBuilder = new StubISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogUserSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, stubSqlParameterBuilder);
            var expected = new List <BlogUser> {
                new BlogUserFactory().Create()
            };

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(expected);

            var actual = sqlServerAdapter.List();

            Assert.Equal(expected, actual);
        }
        public void ListByAuthorId_VerifySqlParameterBuilder()
        {
            var fakeConfig = MakeFakeConfig();
            var mockSqlParameterBuilder = new MockISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogPostSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, mockSqlParameterBuilder);
            var param_id            = new BlogPostFactory().Create().AuthorId;
            var stub_listOfBlogPost = new List <BlogPost> {
                new BlogPostFactory().Create()
            };

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(stub_listOfBlogPost);

            sqlServerAdapter.ListByAuthorId(param_id);

            mockSqlParameterBuilder.VerifyBuildSqlParameterCalled <BlogPost>(1);
        }
        public void GetById_ListReturnedContainsBlogUser_ReturnsExpectedBlogUser()
        {
            var fakeConfig = MakeFakeConfig();
            var stubSqlParameterBuilder = new StubISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogUserSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, stubSqlParameterBuilder);
            var expected            = new BlogUserFactory().Create();
            var stub_listOfBlogUser = new List <BlogUser> {
                expected
            };

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(stub_listOfBlogUser);
            var param_id = expected.UserId;

            var actual = sqlServerAdapter.GetById(param_id);

            Assert.Equal(expected, actual);
        }
        public void GetById_ListReturnedContainsBlogPost_VerifySqlParameterBuilder()
        {
            var fakeConfig = MakeFakeConfig();
            var mockSqlParameterBuilder = new MockISqlParameterBuilder();
            var stubSqlServerDataAccess = new StubISqlServerDataAccess();
            var sqlServerAdapter        = new BlogPostSqlServerAdapter(fakeConfig,
                                                                       stubSqlServerDataAccess, mockSqlParameterBuilder);
            var stub_blogpost       = new BlogPostFactory().Create();
            var stub_listOfBlogPost = new List <BlogPost> {
                stub_blogpost
            };

            stubSqlServerDataAccess.StubExecuteReaderStoredProcedure(stub_listOfBlogPost);
            var param_id = stub_blogpost.PostId;

            sqlServerAdapter.GetById(param_id);

            mockSqlParameterBuilder.VerifyBuildSqlParameterCalled <BlogPost>(1);
        }