public void StartSharing_should_not_throw_ValidationException_for_valid_request() { var request = ShareRequestFactory.CreateCompleteRequestForSingleFile(); Func <Task> act = async() => await _operation.StartSharing(request); act.Should().NotThrow <ValidationException>(); act.Should().NotThrow <NullReferenceException>(); }
public void StartSharing_should_throw_ValidationException_if_secret_is_missing() { var request = ShareRequestFactory.CreateCompleteRequestForSingleFile(); request.User.SecretHash = null; Func <Task> act = async() => await _operation.StartSharing(request); act.Should().ThrowExactly <ValidationException>(); }
public async Task StartSharing_should_save_SharingContext_if_no_duplicate_exists() { A.CallTo(() => _repository.GetSharingContextForUserByInfoHash(A <string> .Ignored, A <string> .Ignored)) .Returns(Task.FromResult <SharingContext>(null)); var request = ShareRequestFactory.CreateCompleteRequestForSingleFile(); await _operation.StartSharing(request); A.CallTo(() => _repository.CreateSharingContext(A <SharingContext> .Ignored)) .MustHaveHappenedOnceExactly(); }
public void StartSharing_should_throw_if_SharingContext_already_exist() { var existingContext = A.Dummy <SharingContext>(); A.CallTo(() => _repository.GetSharingContextForUserByInfoHash(A <string> .Ignored, A <string> .Ignored)) .Returns(existingContext); var request = ShareRequestFactory.CreateCompleteRequestForSingleFile(); Func <Task> act = async() => await _operation.StartSharing(request); act.Should().ThrowExactly <DuplicateSharingContextException>(); }