Пример #1
0
        public async Task SavePosition_UpdatingValidPosition_PositionUpdated()
        {
            var data = new List <Position>
            {
                new Position
                {
                    id          = 999,
                    name        = "q",
                    description = "a"
                }
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Position> >();

            mockSet.As <IDbAsyncEnumerable <Position> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Position>(data.GetEnumerator()));
            mockSet.As <IQueryable <Position> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Position>(data.Provider));
            mockSet.As <IQueryable <Position> >().Setup(m => m.Expression).Returns(data.Expression);
            var mockContext = new Mock <ExtremeSportDBEntities>();

            mockContext.Setup(m => m.Position).Returns(mockSet.Object);
            var positionLogic = new PositionLogic {
                Context = mockContext.Object
            };
            var b = await positionLogic.SavePosition(new DtoPosition
                                                     { Id = 999, Name = "qqqqqqqqqqq", Description = "aaaa" });

            Assert.AreEqual(b, true);
            mockSet.Verify(m => m.Add(It.IsAny <Position>()), Times.Never);
            mockContext.Verify(m => m.SaveChangesAsync(), Times.Once());
        }
Пример #2
0
        public async Task RemovePosition_RemovingPosition_MethodFailed()
        {
            var data = new List <Position>
            {
                new Position {
                    id = 1, name = "BBB"
                },
                new Position {
                    id = 2, name = "ZZZ"
                }
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Position> >();

            mockSet.As <IDbAsyncEnumerable <Position> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Position>(data.GetEnumerator()));
            mockSet.As <IQueryable <Position> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Position>(data.Provider));
            mockSet.As <IQueryable <Position> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Position> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Position> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            var mockContext = new Mock <ExtremeSportDBEntities>();

            mockContext.Setup(m => m.Position).Returns(mockSet.Object);
            var positionLogic = new PositionLogic {
                Context = mockContext.Object
            };
            var b = await positionLogic.RemovePosition(5);

            Assert.AreEqual(b, false);
            mockSet.Verify(m => m.Remove(It.IsAny <Position>()), Times.Never);
            mockContext.Verify(m => m.SaveChangesAsync(), Times.Never);
        }
Пример #3
0
        public async Task GetPosition_ReturningPositionWithSprecifiedId_NullReturned()
        {
            var data = new List <Position>
            {
                new Position {
                    id = 1, name = "BBB"
                },
                new Position {
                    id = 2, name = "ZZZ"
                },
                new Position {
                    id = 3, name = "AAA"
                }
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Position> >();

            mockSet.As <IDbAsyncEnumerable <Position> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Position>(data.GetEnumerator()));
            mockSet.As <IQueryable <Position> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Position>(data.Provider));
            mockSet.As <IQueryable <Position> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Position> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Position> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            var mockContext = new Mock <ExtremeSportDBEntities>();

            mockContext.Setup(c => c.Position).Returns(mockSet.Object);
            var positionLogic = new PositionLogic {
                Context = mockContext.Object
            };
            var pos = await positionLogic.GetPosition(4);

            Assert.IsNull(pos);
        }
Пример #4
0
        //获取所有职位信息
        public ActionResult GetAllPositions(string positionName, string departmentName, int pageIndex, int pageSize)
        {
            PositionLogic logic = new PositionLogic();
            int           rowCount;
            var           data = logic.GetAllPositions(positionName, departmentName, pageIndex, pageSize, out rowCount);

            return(Json(new { Result = data, RowCount = rowCount }));
        }
Пример #5
0
        //保存职位信息
        public ActionResult SavePostion(PositionModel pModel)
        {
            if (pModel.PositionId == null || pModel.PositionId.ToString().Length == 0)
            {
                pModel.PositionId = Guid.Empty;
            }
            PositionLogic logic  = new PositionLogic();
            var           result = logic.SavePosition(pModel);

            return(Json(result));
        }
Пример #6
0
        public EmployeeViewModel()
        {
            ThePosition = new Position();
            TheEmployee = new Employee();


            _poclog            = new PositionLogic();
            _emplog            = new EmployeeLogic();
            ThePerson          = new Person();
            ThePerson          = null;
            _perlog            = new PersonLogic();
            PositionCollection = new ObservableCollection <Position>(_poclog.Get());
            PersonCollection   = new ObservableCollection <Person>(_emplog.GetPersonWithNull());
            EmployeeCollection = new ObservableCollection <Employee>(_emplog.Get());
        }
Пример #7
0
        public void Register(CommonContext commonContext, int index)
        {
            tsvrLogic        = new TSVRLogic();
            positionLogic    = new PositionLogic();
            performanceLogic = new PerformanceLogic();
            account          = new Account();
            portfolioManager = new PortfolioManager();

            logicIndex = index;

            tsvrLogic.Register(commonContext, this);
            positionLogic.Register(commonContext, this);
            performanceLogic.Register(commonContext, this);
            portfolioManager.Register(commonContext, this);
        }
Пример #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Position p = new Position();

            p.Name        = txtName.Text;
            p.Description = txtDescription.Text;
            p.TeamId      = int.Parse(cboTeam.SelectedValue.ToString());
            p.RoleId      = int.Parse(cboRole.SelectedValue.ToString());
            if (_positionToUpdate == null)
            {
                PositionLogic.Add(p);
            }
            else
            {
                PositionLogic.Update(_positionToUpdate, p);
            }
            Close();
        }
Пример #9
0
        public ClientContext()
        {
            DefaultAccount      = new Account();
            PortfolioManager    = new PortfolioManager();
            GeneticEnvironment  = new GeneticEnvironment();
            MarketWatch         = new MarketWatch();
            MarketMeter         = new MarketMeter();
            PerformanceLogic    = new PerformanceLogic();
            PositionLogic       = new PositionLogic();
            StrategyRepository  = new StrategyRepository();
            IndicatorRepository = new IndicatorRepository();
            PersistenceLogic    = new PersistenceLogic();

            PersistenceLogic.Register(this);

            //we need marketWatch.Instruments in strategyRep before connecting to server when loading report
            StrategyRepository.Register(MarketWatch, null);

            //we need this when loading performance
            PerformanceLogic.Register(this);
        }
Пример #10
0
        public async Task GetAllPositions_ReturningAllPositions_AllPositionsReturned()
        {
            var data = new List <Position>
            {
                new Position {
                    name = "BBB"
                },
                new Position {
                    name = "ZZZ"
                },
                new Position {
                    name = "AAA"
                }
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Position> >();

            mockSet.As <IDbAsyncEnumerable <Position> >()
            .Setup(m => m.GetAsyncEnumerator())
            .Returns(new TestDbAsyncEnumerator <Position>(data.GetEnumerator()));
            mockSet.As <IQueryable <Position> >()
            .Setup(m => m.Provider)
            .Returns(new TestDbAsyncQueryProvider <Position>(data.Provider));
            mockSet.As <IQueryable <Position> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Position> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Position> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            var mockContext = new Mock <ExtremeSportDBEntities>();

            mockContext.Setup(c => c.Position).Returns(mockSet.Object);
            var positionLogic = new PositionLogic {
                Context = mockContext.Object
            };
            var pos = await positionLogic.GetAllPositions();

            Assert.AreEqual(3, pos.Count);
            Assert.AreEqual("BBB", pos[0].Name);
            Assert.AreEqual("ZZZ", pos[1].Name);
            Assert.AreEqual("AAA", pos[2].Name);
        }
Пример #11
0
 /// <summary>
 /// 获得公司CompanyID下所有的职位
 /// </summary>
 /// <param name="companyID"></param>
 /// <returns></returns>
 public List <Position> GetPositionByCompanyID(int companyID)
 {
     //List<Position> positionList = new List<Position>();
     //List<Employee> employeeList = GetEmployeeBasicInfoByCompanyID(companyID);
     //foreach (Employee employee in employeeList)
     //{
     //    bool isContain = false;
     //    foreach (Position position in positionList)
     //    {
     //        if (position.Id == employee.Account.Position.Id)
     //        {
     //            isContain = true;
     //            break;
     //        }
     //    }
     //    if (!isContain)
     //    {
     //        positionList.Add(employee.Account.Position);
     //    }
     //}
     //return positionList;
     return(PositionLogic.GetPositionByCompanyID(companyID));
 }
Пример #12
0
 private void ShowPositions()
 {
     positionBindingSource.DataSource = null;
     positionBindingSource.DataSource = PositionLogic.Get();
 }
Пример #13
0
 public PositionViewModel()
 {
     ThePosition        = new Position();
     _poclog            = new PositionLogic();
     PositionCollection = new ObservableCollection <Position>(_poclog.Get());
 }
Пример #14
0
 private void Awake()
 {
     Instance = this;
 }