Exemple #1
0
            public async Task WhenIsRequestAlreadySentGetsCalled()
            {
                Setup();

                _request = new Fixture().Create <Request>();

                RequestsRepository.Setup(repository => repository.GetRequestByUserIdsAndType(It.IsAny <Request>()))
                .ReturnsAsync(_request).Callback <Request>(req => _usedRequest = req);

                _result = await RequestsService.IsRequestAlreadySent(_request);
            }
Exemple #2
0
            public async Task WhenDeclineRequestsGetCalled()
            {
                Setup();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                RequestsRepository
                .Setup(repository => repository
                       .GetRequestByUserIdsAndType(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <RequestType>()))
                .ReturnsAsync((Request)null);

                _result = await RequestsController.DeclineRequest(_userId, _senderId, RequestTypeId);
            }
Exemple #3
0
            public async Task WhenGetOutgoingRequestsGetCalled()
            {
                Setup();

                _requests = new Fixture().CreateMany <Request>().ToList();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                RequestsRepository.Setup(repository => repository.GetRequestsBySenderId(_userId))
                .ReturnsAsync(_requests);

                _result = await RequestsController.GetOutgoingRequests(_userId);
            }
            public async Task WhenGetIncomingRequestsGetCalled()
            {
                Setup();

                var fixture = new Fixture();

                _expectedRequests = fixture.CreateMany <Request>().ToList();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                RequestsRepository.Setup(repo => repo.GetRequestsByReceiverId(It.IsAny <Guid>())).ReturnsAsync(_expectedRequests);

                _result = await RequestsController.GetIncomingRequests(_userId);
            }
Exemple #5
0
            public async Task WhenGetRequestGetsCalled()
            {
                Setup();

                _expectedRequest = new Request
                {
                    ReceiverId = _receiverId, SenderId = _senderId, RequestType = (RequestType)RequestTypeId
                };

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                RequestsRepository.Setup(repository => repository.GetRequestByUserIdsAndType(It.IsAny <Request>()))
                .ReturnsAsync((Request)null).Callback <Request>(req => _usedRequest = req);

                _result = await RequestsController.GetRequest(_receiverId, _senderId, RequestTypeId);
            }
            public async Task WhenValidateAcceptRequestGetsCalled()
            {
                Setup();

                _expectedErrors = new List <Error>
                {
                    new Error("invalid_request", "There is no pending request."),
                    new Error("invalid_request", "You are already connected.")
                };

                _request = new Fixture().Build <Request>().With(request => request.RequestType, RequestType.Friend).Create();

                RequestsRepository.Setup(repository => repository.GetRequestByUserIdsAndType(It.IsAny <Request>()))
                .ReturnsAsync((Request)null);
                RelationshipsService.Setup(service => service.AreAlreadyFriends(It.IsAny <Guid>(), It.IsAny <Guid>()))
                .ReturnsAsync(true);

                _result = await RequestValidator.ValidateAcceptRequest(_request);
            }