public async Task DraftFileBusinessLogic_RestartDraft_Both_Files_Json_Deleted_Bak_Renamed_As_JsonAsync() { // Arrange var aliciaUserId = testUserId; var fileRepository = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, fileRepository); var emptyDraftLockedToAlicia = await testDraftFileBusinessLogic.GetExistingOrNewAsync(testOrganisationId, testSnapshotYear, aliciaUserId); // Confirm both files are there before we start Assert.True(await fileRepository.GetFileExistsAsync(emptyDraftLockedToAlicia.DraftPath)); Assert.True(await fileRepository.GetFileExistsAsync(emptyDraftLockedToAlicia.BackupDraftPath)); // Act await testDraftFileBusinessLogic.RestartDraftAsync(testOrganisationId, testSnapshotYear, aliciaUserId); // Assert // Bak was rolled back and both files are recreated Assert.True(await fileRepository.GetFileExistsAsync(emptyDraftLockedToAlicia.DraftPath)); Assert.True(await fileRepository.GetFileExistsAsync(emptyDraftLockedToAlicia.BackupDraftPath)); // Cleanup await testDraftFileBusinessLogic.DiscardDraftAsync(emptyDraftLockedToAlicia); }
public async Task DraftFileBusinessLogic_RestartDraft_No_Files_Does_Not_FailAsync() { // Arrange var simonUserId = testUserId; var fileRepository = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, fileRepository); var tempDraft = new Draft(testOrganisationId, testSnapshotYear, fileRepository.RootDir); // Act await testDraftFileBusinessLogic.RestartDraftAsync(testOrganisationId, testSnapshotYear, simonUserId); // Assert Assert.False(await fileRepository.GetFileExistsAsync(tempDraft.BackupDraftPath)); }
public async Task DraftFileBusinessLogic_RestartDraft_Only_Json_Ignored_Nothing_To_Rollback_FromAsync() { // Arrange var anneUserId = testUserId; var fileRepository = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, fileRepository); var emptyDraftLockedToAnne = await testDraftFileBusinessLogic.GetExistingOrNewAsync(testOrganisationId, testSnapshotYear, anneUserId); await testDraftFileBusinessLogic.CommitDraftAsync(emptyDraftLockedToAnne); // Act await testDraftFileBusinessLogic.RestartDraftAsync(testOrganisationId, testSnapshotYear, anneUserId); // Assert Assert.False(await fileRepository.GetFileExistsAsync(emptyDraftLockedToAnne.BackupDraftPath)); // Cleanup await testDraftFileBusinessLogic.DiscardDraftAsync(emptyDraftLockedToAnne); }