Пример #1
0
        public void ClearDatabase_VerifyWriter()
        {
            var stubReader     = new StubIFileReader();
            var mockWriter     = new MockIFileWriter();
            var fileDataAccess = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var param_filePath = "path/to/the/file.json";

            fileDataAccess.ClearDatabase(param_filePath);

            mockWriter.VerifyWrite(param_filePath, false, "");
        }
Пример #2
0
        public void OverwriteToDatabase_ListOfEntityIsEmpty_VerifyWriter()
        {
            var stubReader         = new StubIFileReader();
            var mockWriter         = new MockIFileWriter();
            var fileDataAccess     = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var param_filePath     = "path/to/the/file.json";
            var param_listOfEntity = new List <FakeBlogModel>();

            fileDataAccess.OverwriteDatabase(param_filePath, param_listOfEntity);

            mockWriter.VerifyWriteNeverCalled();
        }
Пример #3
0
        public void WriteToDatabase_EntityIsNull_VerifyWriter()
        {
            var           stubReader     = new StubIFileReader();
            var           mockWriter     = new MockIFileWriter();
            var           fileDataAccess = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var           param_filePath = "path/to/the/file.json";
            FakeBlogModel param_entity   = null;

            fileDataAccess.WriteToDatabase(param_filePath, param_entity);

            mockWriter.VerifyWriteNeverCalled();
        }
Пример #4
0
        public void OverwriteDatabase_ListOfEntityIsValid_VerifyWriter()
        {
            var stubReader         = new StubIFileReader();
            var mockWriter         = new MockIFileWriter();
            var fileDataAccess     = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var param_filePath     = "path/to/the/file.json";
            var param_listOfEntity = new List <FakeBlogModel> {
                new FakeBlogModel()
            };

            fileDataAccess.OverwriteDatabase(param_filePath, param_listOfEntity);

            mockWriter.VerifyWrite(param_filePath, false, JsonConvert.SerializeObject(param_listOfEntity));
        }
Пример #5
0
        public void WriteToDatabase_EntityIsValidAndDatabaseIsEmpty_VerifyWriter()
        {
            var           stubReader            = new StubIFileReader();
            var           mockWriter            = new MockIFileWriter();
            var           fileDataAccess        = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var           param_filePath        = "path/to/the/file.json";
            FakeBlogModel param_entity          = new FakeBlogModel();
            var           expected_listOfEntity = new List <FakeBlogModel> {
                param_entity
            };

            fileDataAccess.WriteToDatabase(param_filePath, param_entity);

            mockWriter.VerifyWrite(param_filePath, false, JsonConvert.SerializeObject(expected_listOfEntity));
        }
Пример #6
0
        public void WriteToDatabase_ListOfEntityIsValidAndDatabaseContainsOneObject_VerifyWriter()
        {
            var stubReader         = new StubIFileReader();
            var mockWriter         = new MockIFileWriter();
            var fileDataAccess     = new FileDataAccess <FakeBlogModel>(stubReader, mockWriter);
            var param_filePath     = "path/to/the/file.json";
            var param_listOfEntity = new List <FakeBlogModel> {
                new FakeBlogModel()
            };
            var stub_listOfEntity = new List <FakeBlogModel> {
                new FakeBlogModel()
            };

            stubReader.StubRead(JsonConvert.SerializeObject(stub_listOfEntity));
            stub_listOfEntity.AddRange(param_listOfEntity);

            fileDataAccess.WriteToDatabase(param_filePath, param_listOfEntity);

            mockWriter.VerifyWrite(param_filePath, false, JsonConvert.SerializeObject(stub_listOfEntity));
        }