Ejemplo n.º 1
0
        public void Delete_VerifyDataAccess()
        {
            var fakeConfig         = MakeFakeConfig();
            var mockFileDataAccess = new MockIFileDataAccess <BlogUser>();
            var fileAdapter        = new BlogUserFileAdapter(fakeConfig, mockFileDataAccess);
            var param_entity       = new BlogUserFactory().Create();
            var stub_blogUser      = new BlogUserFactory().Create();

            stub_blogUser.UserId = Guid.Parse("55555555-5555-5555-5555-555555555555");
            var stub_list = new List <BlogUser> {
                param_entity, stub_blogUser
            };

            mockFileDataAccess.StubReadDatabase(stub_list);
            var expected_readDBfilePath      = fakeConfig[KeyChain.FileDataAccess_BlogUser_DatabasePath];
            var expected_overwriteDBfilePath = fakeConfig[KeyChain.FileDataAccess_BlogUser_DatabasePath];
            var expected_overwriteDB_newList = new List <BlogUser> {
                stub_blogUser
            };

            fileAdapter.Delete(param_entity);

            mockFileDataAccess.VerifyReadDatabase(expected_readDBfilePath);
            mockFileDataAccess.VerifyOverwriteDatabase(expected_overwriteDBfilePath, expected_overwriteDB_newList);
        }
Ejemplo n.º 2
0
        public void Edit_VerifyDataAccess()
        {
            var fakeConfig         = MakeFakeConfig();
            var mockFileDataAccess = new MockIFileDataAccess <BlogPost>();
            var fileAdapter        = new BlogPostFileAdapter(fakeConfig, mockFileDataAccess);
            var param_entity       = new BlogPostFactory().Create();
            var stub_blogPost      = new BlogPostFactory().Create();

            stub_blogPost.PostId = Guid.Parse("55555555-5555-5555-5555-555555555555");
            var stub_list = new List <BlogPost> {
                param_entity, stub_blogPost
            };

            mockFileDataAccess.StubReadDatabase(stub_list);
            param_entity.PostBody = "This is an edited PostBody!";
            var expected_readDBfilePath      = fakeConfig[KeyChain.FileDataAccess_BlogPost_DatabasePath];
            var expected_overwriteDBfilePath = fakeConfig[KeyChain.FileDataAccess_BlogPost_DatabasePath];
            var expected_overwriteDB_newList = new List <BlogPost> {
                stub_blogPost, param_entity
            };

            fileAdapter.Edit(param_entity);

            mockFileDataAccess.VerifyReadDatabase(expected_readDBfilePath);
            mockFileDataAccess.VerifyOverwriteDatabase(expected_overwriteDBfilePath, expected_overwriteDB_newList);
        }
Ejemplo n.º 3
0
        public void DeleteByAuthorId_VerifyDataAccess()
        {
            var fakeConfig         = MakeFakeConfig();
            var mockFileDataAccess = new MockIFileDataAccess <BlogPost>();
            var fileAdapter        = new BlogPostFileAdapter(fakeConfig, mockFileDataAccess);
            var stub_blogPost1     = new BlogPostFactory().Create();
            var stub_blogPost2     = new BlogPostFactory().Create();

            stub_blogPost2.AuthorId = Guid.Parse("55555555-5555-5555-5555-555555555555");
            var stub_list = new List <BlogPost> {
                stub_blogPost1, stub_blogPost2
            };

            mockFileDataAccess.StubReadDatabase(stub_list);
            var expected_readDBfilePath      = fakeConfig[KeyChain.FileDataAccess_BlogPost_DatabasePath];
            var expected_overwriteDBfilePath = fakeConfig[KeyChain.FileDataAccess_BlogPost_DatabasePath];
            var expected_overwriteDB_newList = new List <BlogPost> {
                stub_blogPost1
            };

            fileAdapter.DeleteAllByAuthorId(stub_blogPost2.AuthorId);

            mockFileDataAccess.VerifyReadDatabase(expected_readDBfilePath);
            mockFileDataAccess.VerifyOverwriteDatabase(expected_overwriteDBfilePath, expected_overwriteDB_newList);
        }
Ejemplo n.º 4
0
        public void List_VerifyFileDataAccess()
        {
            var fakeConfig         = MakeFakeConfig();
            var mockFileDataAccess = new MockIFileDataAccess <BlogUser>();
            var fileAdapter        = new BlogUserFileAdapter(fakeConfig, mockFileDataAccess);
            var stub_blogUser      = new BlogUserFactory().Create();
            var stub_list          = new List <BlogUser> {
                stub_blogUser
            };

            mockFileDataAccess.StubReadDatabase(stub_list);
            var expected_readDBfilePath = fakeConfig[KeyChain.FileDataAccess_BlogUser_DatabasePath];

            fileAdapter.List();

            mockFileDataAccess.VerifyReadDatabase(expected_readDBfilePath);
        }
Ejemplo n.º 5
0
        public void GetById_VerifyFileDataAccess()
        {
            var fakeConfig         = MakeFakeConfig();
            var mockFileDataAccess = new MockIFileDataAccess <BlogUser>();
            var fileAdapter        = new BlogUserFileAdapter(fakeConfig, mockFileDataAccess);
            var stub_blogUser1     = new BlogUserFactory().Create();
            var stub_blogUser2     = new BlogUserFactory().Create();

            stub_blogUser2.UserId = Guid.Parse("55555555-5555-5555-5555-555555555555");
            var stub_list = new List <BlogUser> {
                stub_blogUser1, stub_blogUser2
            };

            mockFileDataAccess.StubReadDatabase(stub_list);
            var expected_readDBfilePath = fakeConfig[KeyChain.FileDataAccess_BlogUser_DatabasePath];

            fileAdapter.GetById(stub_blogUser2.UserId);

            mockFileDataAccess.VerifyReadDatabase(expected_readDBfilePath);
        }