public void Constructor_SetsProperties()
        {
            var dut = new UnAcceptPunchOutCommand(
                1,
                _invitationRowVersion,
                _constructionCompanyRowVersion);

            Assert.AreEqual(1, dut.InvitationId);
            Assert.AreEqual(_invitationRowVersion, dut.InvitationRowVersion);
            Assert.AreEqual(_constructionCompanyRowVersion, dut.ParticipantRowVersion);
        }
예제 #2
0
        public async Task ValidateAsync_OnUnAcceptInvitationCommand_ShouldReturnFalse_WhenNoAccessToProject()
        {
            // Arrange
            var command = new UnAcceptPunchOutCommand(
                _invitationIdWithoutAccessToProject,
                null,
                null);

            // act
            var result = await _dut.ValidateAsync(command);

            // Assert
            Assert.IsFalse(result);
        }
예제 #3
0
        public void Setup_OkState()
        {
            _invitationValidatorMock = new Mock <IInvitationValidator>();
            _rowVersionValidatorMock = new Mock <IRowVersionValidator>();
            _rowVersionValidatorMock.Setup(r => r.IsValid(_invitationRowVersion)).Returns(true);
            _rowVersionValidatorMock.Setup(r => r.IsValid(_participantRowVersion)).Returns(true);
            _invitationValidatorMock.Setup(inv => inv.IpoExistsAsync(_id, default)).Returns(Task.FromResult(true));
            _invitationValidatorMock.Setup(inv => inv.IpoIsInStageAsync(_id, IpoStatus.Accepted, default)).Returns(Task.FromResult(true));
            _invitationValidatorMock.Setup(inv => inv.CurrentUserIsAdminOrValidAccepterParticipantAsync(_id, default)).Returns(Task.FromResult(true));
            _invitationValidatorMock.Setup(inv => inv.IpoHasAccepterAsync(_id, default)).Returns(Task.FromResult(true));
            _command = new UnAcceptPunchOutCommand(
                _id,
                _invitationRowVersion,
                _participantRowVersion);

            _dut = new UnAcceptPunchOutCommandValidator(_invitationValidatorMock.Object, _rowVersionValidatorMock.Object);
        }
        public void Setup()
        {
            _plantProviderMock = new Mock <IPlantProvider>();
            _plantProviderMock
            .Setup(x => x.Plant)
            .Returns(_plant);

            _unitOfWorkMock = new Mock <IUnitOfWork>();

            _currentUserProviderMock = new Mock <ICurrentUserProvider>();
            _currentUserProviderMock
            .Setup(x => x.GetCurrentUserOid()).Returns(_azureOidForCurrentUser);

            _permissionCacheMock = new Mock <IPermissionCache>();

            //create invitation
            _invitation = new Invitation(
                _plant,
                _projectName,
                _title,
                _description,
                _typeDp,
                new DateTime(),
                new DateTime(),
                null,
                new List <McPkg> {
                new McPkg(_plant, _projectName, "Comm", "Mc", "d", "1|2")
            },
                null)
            {
                MeetingId = _meetingId
            };

            var participant1 = new Participant(
                _plant,
                Organization.Contractor,
                IpoParticipantType.FunctionalRole,
                _functionalRoleCode,
                null,
                null,
                null,
                null,
                null,
                0);

            _invitation.AddParticipant(participant1);
            var participant2 = new Participant(
                _plant,
                Organization.ConstructionCompany,
                IpoParticipantType.Person,
                null,
                _firstName,
                _lastName,
                "OlaN",
                "*****@*****.**",
                _azureOidForCurrentUser,
                1);

            participant2.SetProtectedIdForTesting(_participantId);
            _invitation.AddParticipant(participant2);
            var currentPerson = new Person(_azureOidForCurrentUser, _firstName, _lastName, null, null);

            _invitation.CompleteIpo(participant2, participant2.RowVersion.ConvertToString(), currentPerson, new DateTime());

            _invitation.AcceptIpo(participant2, participant2.RowVersion.ConvertToString(), currentPerson, new DateTime());

            _invitationRepositoryMock = new Mock <IInvitationRepository>();
            _invitationRepositoryMock
            .Setup(x => x.GetByIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(_invitation));

            //command
            _command = new UnAcceptPunchOutCommand(
                _invitation.Id,
                _invitationRowVersion,
                _participantRowVersion);

            _dut = new UnAcceptPunchOutCommandHandler(_invitationRepositoryMock.Object,
                                                      _unitOfWorkMock.Object,
                                                      _currentUserProviderMock.Object,
                                                      _plantProviderMock.Object,
                                                      _permissionCacheMock.Object);
        }