public void FromInvestorApproveToInvestorResponsedTest()
        {
            InvestorApproveUoW target = CreateUoW();

            Assert.IsFalse(target.FromInvestorApproveToInvestorResponsed());

            _currentProject.Responses = new List <InvestorResponse>();
            _currentProject.Responses.Add(new InvestorResponse {
                IsVerified = false
            });
            _currentProject.Responses.Add(new InvestorResponse {
                IsVerified = false
            });
            target = CreateUoW();
            Assert.IsTrue(target.FromInvestorApproveToInvestorResponsed());

            _currentProject.Responses = new List <InvestorResponse>();
            _currentProject.Responses.Add(new InvestorResponse {
                IsVerified = false
            });
            _currentProject.Responses.Add(new InvestorResponse {
                IsVerified = true
            });
            target = CreateUoW();
            Assert.IsFalse(target.FromInvestorApproveToInvestorResponsed());
        }
        public void OnInvestorApproveEntryTest()
        {
            bool wasUserNotificate  = false;
            bool wasAdminNotificate = false;

            _adminNotification.Setup(a => a.InvestorResponsed(It.IsAny <Project>()))
            .Callback(() => { wasAdminNotificate = true; });
            _userNotification.Setup(u => u.InvestorResponsed(It.IsAny <Project>())).Callback(() => { wasUserNotificate = true; });

            _currentProject.WorkflowState.CurrentState = ProjectWorkflow.State.OnMap;
            _currentProject.Responses = new List <InvestorResponse>
            {
                new InvestorResponse {
                    IsVerified = false
                },
                new InvestorResponse {
                    IsVerified = false
                },
                new InvestorResponse {
                    IsVerified = true
                }
            };

            InvestorApproveUoW target = CreateUoW();

            target.OnInvestorApproveEntry();

            Assert.IsTrue(wasAdminNotificate);
            Assert.IsTrue(wasUserNotificate);
            Assert.IsTrue(
                _repository.GetOne <Project>(
                    p => p._id == _currentProject._id).WorkflowState.CurrentState == ProjectWorkflow.State.InvestorApprove);

            Assert.IsTrue(_repository.GetOne <Project>(
                              p => p._id == _currentProject._id).WorkflowState.History.Count > 0);

            Assert.IsTrue(_repository.GetOne <Project>(
                              p => p._id == _currentProject._id)
                          .WorkflowState.History.Find(
                              h =>
                              h.Editor == _userName &&
                              h.From == ProjectWorkflow.State.OnMap &&
                              h.To == ProjectWorkflow.State.InvestorApprove) != null);
        }
        public void InvestorApproveUoWConstructorTest()
        {
            InvestorApproveUoW target = CreateUoW();

            Assert.IsNotNull(target);
        }
        public void FromOnMapToInvestorApproveTest()
        {
            InvestorApproveUoW target = CreateUoW();

            Assert.IsTrue(target.FromOnMapToInvestorApprove());
        }
        public UnitsOfWorkContainer(Project currentProject,
                                    IRepository repository,
                                    IUserNotification userNotification,
                                    IAdminNotification adminNotification,
                                    IInvestorNotification investorNotification,
                                    string userName,
                                    IEnumerable <string> roles)
        {
            _currentProject       = currentProject;
            _repository           = repository;
            _userNotification     = userNotification;
            _adminNotification    = adminNotification;
            _investorNotification = investorNotification;
            _userName             = userName;
            _roles = roles;

            OpenUoW = new OpenUoW(_currentProject,
                                  _repository,
                                  _userNotification,
                                  _adminNotification,
                                  _investorNotification,
                                  _userName,
                                  _roles);
            OnMapUoW = new OnMapUoW(_currentProject,
                                    _repository,
                                    _userNotification,
                                    _adminNotification,
                                    _investorNotification,
                                    _userName,
                                    _roles);
            InvestorApproveUoW = new InvestorApproveUoW(_currentProject,
                                                        _repository,
                                                        _userNotification,
                                                        _adminNotification,
                                                        _investorNotification,
                                                        _userName,
                                                        _roles);

            WaitIspolcomUoW = new WaitIspolcomUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            WaitInvolvedUoW = new WaitInvolvedUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            WaitComissionUoW = new WaitComissionUoW(_currentProject,
                                                    _repository,
                                                    _userNotification,
                                                    _adminNotification,
                                                    _investorNotification,
                                                    _userName,
                                                    _roles);
            RealizationUoW = new RealizationUoW(_currentProject,
                                                _repository,
                                                _userNotification,
                                                _adminNotification,
                                                _investorNotification,
                                                _userName,
                                                _roles);
            PlanCreatingUoW = new PlanCreatingUoW(_currentProject,
                                                  _repository,
                                                  _userNotification,
                                                  _adminNotification,
                                                  _investorNotification,
                                                  _userName,
                                                  _roles);
            OnIspolcomUoW = new OnIspolcomUoW(_currentProject,
                                              _repository,
                                              _userNotification,
                                              _adminNotification,
                                              _investorNotification,
                                              _userName,
                                              _roles);
            OnComissionUoW = new OnComissionUoW(_currentProject,
                                                _repository,
                                                _userNotification,
                                                _adminNotification,
                                                _investorNotification,
                                                _userName,
                                                _roles);
            MinEconomyUoW = new MinEconomyUoW(_currentProject,
                                              _repository,
                                              _userNotification,
                                              _adminNotification,
                                              _investorNotification,
                                              _userName,
                                              _roles);
            IspolcomFixesUoW = new IspolcomFixesUoW(_currentProject,
                                                    _repository,
                                                    _userNotification,
                                                    _adminNotification,
                                                    _investorNotification,
                                                    _userName,
                                                    _roles);
            InvolvedorganizationsUoW = new InvolvedOrganizationsUoW(_currentProject,
                                                                    _repository,
                                                                    _userNotification,
                                                                    _adminNotification,
                                                                    _investorNotification,
                                                                    _userName,
                                                                    _roles);
            DocumentSendingUoW = new DocumentSendingUoW(_currentProject,
                                                        _repository,
                                                        _userNotification,
                                                        _adminNotification,
                                                        _investorNotification,
                                                        _userName,
                                                        _roles);
            ComissionFixesUoW = new ComissionFixesUoW(_currentProject,
                                                      _repository,
                                                      _userNotification,
                                                      _adminNotification,
                                                      _investorNotification,
                                                      _userName,
                                                      _roles);
            DoneUoW = new DoneUoW(_currentProject,
                                  _repository,
                                  _userNotification,
                                  _adminNotification,
                                  _investorNotification,
                                  _userName,
                                  _roles);

            var dict = new Dictionary <Type, IState>();

            dict.Add(OnMapUoW.GetType(), OnMapUoW);
            AttributeStateMachineBuilder.InitializeStates(dict);
        }