public async Task DraftFileBusinessLogic_KeepDraftFileLockedToUser_When_Not_Json_Return_NullAsync() { // Arrange var stewardUserId = testUserId; var fileRepo = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, fileRepo); var emptyDraftLockedToSteward = await testDraftFileBusinessLogic.GetExistingOrNewAsync(testOrganisationId, testSnapshotYear, stewardUserId); var creationTimeStamp = emptyDraftLockedToSteward.LastWrittenDateTime; emptyDraftLockedToSteward.HasDraftBeenModifiedDuringThisSession = true; Thread.Sleep( 1000); // Delay between creating the file and the subsequent request to keep it locked to steward. // Act // the object 'emptyDraftLockedToSteward' will be modified by the method await testDraftFileBusinessLogic.KeepDraftFileLockedToUserAsync(emptyDraftLockedToSteward, stewardUserId); // Assert Assert.NotNull(emptyDraftLockedToSteward, "Expected a draft to be available as we're only requesting a lock"); Assert.Null(emptyDraftLockedToSteward.ReturnViewModelContent, "Haven't added any data, so the content should be empty"); Assert.True(emptyDraftLockedToSteward.IsUserAllowedAccess, "Steward must be able to access the draft"); Assert.AreEqual(stewardUserId, emptyDraftLockedToSteward.LastWrittenByUserId, "Should have been locked to Steward"); Assert.True( emptyDraftLockedToSteward.HasDraftBeenModifiedDuringThisSession, "the method 'KeepDraftFileLockedToUser' is expected to modified some fields, but 'IsDraftDirty' must be left alone, as it is the front end's responsibility to determine if the draft contains new values or not - only the individual pages can determine if the user has typed something on screen"); Assert.True( creationTimeStamp < emptyDraftLockedToSteward.LastWrittenDateTime, $"The draft file's metadata has been changed to reflect that Steward wants to keep the file locked to him, so it must have a timeStamp '{emptyDraftLockedToSteward.LastWrittenDateTime}' different-and-older than the initial file '{creationTimeStamp}'"); await testDraftFileBusinessLogic.DiscardDraftAsync(emptyDraftLockedToSteward); }