示例#1
0
        public void Edit_Line()
        {
            var controller  = new LinesController(new LineBLL(new LineRepositoryStab()));
            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var line = new Line {
                LineId = 1, LineStations = null, Name = "Test"
            };
            var actionResult = (RedirectToRouteResult)controller.Add(line);

            Assert.IsNotNull(actionResult, "Not a redirect result");
            Assert.IsFalse(actionResult.Permanent);
            Assert.AreEqual("Index", actionResult.RouteValues["Action"]);
        }
示例#2
0
        public void Add()
        {
            var controller  = new LinesController(new LineBLL(new LineRepositoryStab()));
            var sessionMock = new TestControllerBuilder();

            sessionMock.InitializeController(controller);
            controller.Session["AuthenticatedUser"] = new DbUser
            {
                Username = "******",
                Password = null,
                Salt     = null
            };
            var line         = new Line();
            var actionResult = (ViewResult)controller.Add();

            var result = (Line)actionResult.Model;

            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(result.LineId, line.LineId);
            Assert.AreEqual(result.Name, line.Name);
            Assert.AreEqual(result.LineStations, line.LineStations);
        }
        protected override RESULT Process(StringBuilder messager)
        {
            var data = this.GetData <TengxunStockInfoEntity>(CollectClient.ID);

            if (data != null)
            {
                Balancer.Add(new KeyValuePair <DateTime, decimal>(data.Time, data.Current)).ForEach(pair => LinesController.Add(pair));
                LinesController.Process();
                this.logger.Write(TYPE.INFO, LinesController.ToString());
            }

            ProcessCommand(this.GetData <SGCommand>(SocketClient.ID));

            //if (data != null) this.logger.Write(TYPE.INFO, data.ToString());
            return(RESULT.OK);
        }