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); }