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, ""); }
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(); }
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(); }
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)); }
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)); }
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)); }