Beispiel #1
0
        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>();
        }
Beispiel #2
0
        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>();
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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>();
        }