Пример #1
0
        public async void GetTripsByLineID_Exists()
        {
            var repo = new Mock <ITripRepository> ();
            var uow  = new Mock <IUnitOfWork> ();

            string lineID            = "Line:1";
            string pathID            = "Path:1";
            string tripDepartureTime = "20:12:10";

            LineId line = new LineId(lineID);

            var trip  = new Trip(lineID, pathID, tripDepartureTime);
            var trips = new List <Trip> ()
            {
                trip
            };

            var tripDTO  = new TripDTO(trip.Id.AsGuid(), new LineId(lineID), new PathId(pathID), tripDepartureTime);
            var tripsDTO = new List <TripDTO> ()
            {
                tripDTO
            };

            repo.Setup(_ => _.GetTripsByLineID(line)).ReturnsAsync(trips);

            var service = new TripService(repo.Object, uow.Object);

            var actual = await service.GetTripsByLineID(line);

            Assert.Equal(tripsDTO, actual);
        }
Пример #2
0
        public async void GetByLineId()
        {
            var tripServiceMock = new Mock <ITripService> ();
            var pathServiceMock = new Mock <IPathService> ();

            string lineID            = "Line:1";
            string pathID            = "Path:1";
            string tripDepartureTime = "20:12:10";

            var trip = new Trip(lineID, pathID, tripDepartureTime);

            var tripDTO  = new TripDTO(trip.Id.AsGuid(), new LineId(lineID), new PathId(pathID), tripDepartureTime);
            var tripsDTO = new List <TripDTO> ()
            {
                tripDTO
            };

            var line = new LineId(lineID);

            tripServiceMock.Setup(_ => _.GetTripsByLineID(line)).ReturnsAsync(tripsDTO);

            var controller = new TripController(tripServiceMock.Object, pathServiceMock.Object);

            var actual = await controller.GetByLineId(lineID);

            Assert.Equal(tripsDTO, actual.Value);
        }
Пример #3
0
 private Assign(Location loc, string builtIn, LineId line)
     : base(line)
 {
     this.location = loc;
     this.value = null;
     this.builtIn = builtIn;
 }
Пример #4
0
 public Input(Expression inputPromptExpr, Block inputs, LineId line)
     : base(line)
 {
     this.inputPrompt = new Print(
         new Expression[] { inputPromptExpr, new StringLiteral("\0", line) }, line);
     this.inputs = inputs;
 }
Пример #5
0
 public TripDTO(Guid Id, LineId lineID, PathId pathID, string tripDepartureTime, List <NodePassageDTO> nodePassageListDTO)
 {
     this.Id                 = Id;
     this.lineID             = lineID;
     this.pathID             = pathID;
     this.tripDepartureTime  = tripDepartureTime;
     this.nodePassageListDTO = new List <NodePassageDTO> (nodePassageListDTO);
 }
 protected RelationalExpression(Expression e1,
     Expression e2, bool not, LineId line)
     : base(line)
 {
     this.e1 = e1;
     this.e2 = e2;
     this.not = not;
 }
Пример #7
0
 public If(Expression conditional, string label, string elseLabel,
     LineId line)
     : base(line)
 {
     jmp = new Goto(label, line);
     elseJmp = new Goto(elseLabel, line);
     this.conditional = conditional;
 }
Пример #8
0
 public For(Assign init, Expression comparison, Assign update, Statement stmt, LineId line)
     : base(line)
 {
     this.init = init;
     this.comparison = comparison;
     this.stmt = stmt;
     this.update = update;
 }
Пример #9
0
        public Task <List <Trip> > GetTripsByLineID(LineId otherLineID)
        {
            var query =
                from t in this.trips
                where t.lineID.id == otherLineID.id
                select t;

            return(Task.Run(() => query.ToList <Trip> ()));
        }
Пример #10
0
 public ImportedTripDTO(string key, Guid Id, LineId lineID, PathId pathID, string tripDepartureTime)
 {
     this.key                = key;
     this.Id                 = Id;
     this.lineID             = lineID;
     this.pathID             = pathID;
     this.tripDepartureTime  = tripDepartureTime;
     this.nodePassageListDTO = new List <NodePassageDTO> ();
 }
Пример #11
0
        public override int GetHashCode()
        {
            int hashCode = -96987508;

            hashCode = hashCode * -1521134295 + LineId.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(name_line);

            hashCode = hashCode * -1521134295 + nbr_place_line.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Enum> .Default.GetHashCode(typee);

            return(hashCode);
        }
Пример #12
0
        public override string ToString()
        {
            var sb     = new StringBuilder();
            var lineId = LineId.ToList();

            lineId.Insert(0, 0x00);
            var l = Convert.ToUInt32(lineId.ByteArrToHexStr(), 16);

            sb.Append($"标识位:{BitConverter.GetBytes(BeginMark).ByteArrToHexStr()},数据长度:{DataLength},版本:{Version},序列号1:{SerialNum1},序列号2:{SerialNum2},检测线状态:{Convert.ToString(WireStatus,2).PadLeft(8,'0')},状态位:{Convert.ToString(Status,2).PadLeft(8,'0')},车辆编号:{VehicleNum},时间:{GetDateTimeStr()},命令字:0x{CommandCode:X2},线路ID:{l},子线路编码:{SubLineCode},校验码:{CheckCode}.\r\n");
            sb.Append(Body);
            return(sb.ToString());
        }
Пример #13
0
        public void BuildTreeNodes()
        {
            string lineShadow = "";

            if (ParentLine != null)
            {
                lineShadow = ParentLine.LineShadow + "-" + LineId.ToString().PadRight(15, ' ');
            }
            else
            {
                lineShadow = LineId.ToString().PadRight(15, ' ');
            }
            this.LineShadow = lineShadow;
        }
Пример #14
0
        public MyBudget.Commands.UpdateLine PrepareUpdateLine(string userId)
        {
            var expense = new Expense(new Amount(Currencies.Parse(CurrencyISOCode), Amount), Date, Category, Description, DistributionKey);

            return(new MyBudget.Commands.UpdateLine
            {
                UserId = userId,
                BudgetId = BudgetId.ToString(),
                LineId = LineId.ToString(),
                Id = Guid.NewGuid(),
                Timestamp = DateTime.Now,
                Expense = expense,
            });
        }
Пример #15
0
        public async Task <List <TripDTO> > GetTripsByLineID(LineId lineId)
        {
            var tripList = await this._repo.GetTripsByLineID(lineId);

            var tripDTOlist = new List <TripDTO> ();

            foreach (var trip in tripList)
            {
                TripDTO tripDTO = _mapper.DomainToDTO(trip);

                tripDTOlist.Add(tripDTO);
            }

            return(tripDTOlist);
        }
Пример #16
0
        public CreateLine ToCreateLine(DateTime timestamp, BudgetId budgetId, string userId, IEnumerable <MyBudget.Projections.Category> categories)
        {
            var category   = Categoria.Trim().Replace((char)160, ' ');
            var categoryId = categories.FirstOrDefault(d => string.Compare(d.Name, category, true) == 0).Id;
            var expense    = new Expense(new Amount(Currencies.Euro(), Spesa), Data, categoryId, Descrizione, DistributionKey);

            return(new CreateLine
            {
                Id = Guid.NewGuid(),
                Timestamp = timestamp,
                BudgetId = budgetId.ToString(),
                LineId = LineId.Create(budgetId).ToString(),
                UserId = userId,
                Expense = expense,
            });
        }
Пример #17
0
        public static CreateLine ToCreateLine(this Movement mov, BudgetId budgetId, string userId, IEnumerable <MyBudget.Projections.Category> categories)
        {
            var category   = mov.Category.Trim().Replace((char)160, ' ');
            var categoryId = categories.FirstOrDefault(d => string.Compare(d.Name, category, true) == 0).Id;

            var expense = new Expense(new Amount(Currencies.Euro(), Convert.ToDecimal(mov.Import)), mov.DateTime, categoryId, mov.ShortDescription);


            return(new CreateLine
            {
                Id = Guid.NewGuid(),
                Timestamp = DateTime.Now,
                BudgetId = budgetId.ToString(),
                LineId = LineId.Create(budgetId).ToString(),
                UserId = userId,
                Expense = expense,
            });
        }
Пример #18
0
        public async void GetTripsByLineID_Empty()
        {
            var repo = new Mock <ITripRepository> ();
            var uow  = new Mock <IUnitOfWork> ();

            LineId line = new LineId("Line:2");

            var expected = new List <TripDTO> ()
            {
            };

            repo.Setup(_ => _.GetTripsByLineID(line)).ReturnsAsync(new List <Trip> ());

            var service = new TripService(repo.Object, uow.Object);

            var actual = await service.GetTripsByLineID(line);

            Assert.Equal(expected, actual);
        }
Пример #19
0
 public TypeCheckException(string message, LineId line)
     : base(message, line)
 {
 }
Пример #20
0
 public static RelationalExpression CompareNotEquals(
     Expression e1, Expression e2, LineId line)
 {
     return new Equals(e1, e2, true, line);
 }
Пример #21
0
 public override string ToString()
 {
     return(LineId.ToString() + " " + ColumnIndex.ToString());
 }
Пример #22
0
 public static Assign ReadConsole(Location loc, LineId line)
 {
     return new Assign(loc, inputExpr, line);
 }
Пример #23
0
 public Assign(Location loc, Expression value, LineId line)
     : base(line)
 {
     this.location = loc;
     this.value = value;
 }
Пример #24
0
 public Power(Expression e1, Expression e2, LineId line)
     : base(e1, e2, line)
 {
 }
Пример #25
0
 public Function(string name, LineId line, params Expression[] expressions)
     : base(line)
 {
     this.functionName = name;
     this.exprs = expressions;
     argsTypes = new BasicType[exprs.Length];
 }
Пример #26
0
 public Return(LineId line)
     : base(line)
 {
 }
Пример #27
0
 public GreaterThan(Expression expr1, Expression expr2, bool not,
     LineId line)
     : base(expr1, expr2, not, line)
 {
 }
Пример #28
0
 public override int GetHashCode()
 {
     return(LineId != null?LineId.GetHashCode() : 0);
 }
Пример #29
0
 public static RelationalExpression CompareLessThan(
     Expression e1, Expression e2, LineId line)
 {
     return new LessThan(e1, e2, false, line);
 }
Пример #30
0
 protected BinaryOperator(Expression e1, Expression e2, LineId line)
     : base(line)
 {
     this.expr1 = e1;
     this.expr2 = e2;
 }
Пример #31
0
 public Equals(Expression e1, Expression e2, bool not, LineId line)
     : base(e1, e2, not, line)
 {
 }
Пример #32
0
 public static RelationalExpression CompareLessThanEquals(
     Expression e1, Expression e2, LineId line)
 {
     return new GreaterThan(e1, e2, true, line);
 }
Пример #33
0
        Label lineLabel; // A .NET label used to mark this location.

        #endregion Fields

        #region Constructors

        protected Statement(LineId line)
            : base(line)
        {
        }
Пример #34
0
 public LocationReference(Location loc, LineId line)
     : base(line)
 {
     this.location = loc;
 }
Пример #35
0
 public End(LineId line)
     : base(line)
 {
 }
Пример #36
0
 public OnGoto(Expression number, List<string> targets, LineId line)
     : base(line)
 {
     this.numericExpression = number;
     this.targets = targets;
 }
Пример #37
0
 public Negative(Expression value, LineId line)
     : base(line)
 {
     this.value = value;
 }
Пример #38
0
 public Concatenate(Expression s1, Expression s2, LineId line)
     : base(line)
 {
     this.s1 = s1;
     this.s2 = s2;
 }
Пример #39
0
        Label returnLabel; // This is the Label the subroutine should return to.

        #endregion Fields

        #region Constructors

        public Gosub(string destLabel, LineId line)
            : base(line)
        {
            this.destLabel = destLabel;
        }
Пример #40
0
 public Subtract(Expression e1, Expression e2, LineId line)
     : base(e1, e2, line)
 {
 }
Пример #41
0
 public Goto(string label, LineId line)
     : base(line)
 {
     this.destLabel = label;
 }
Пример #42
0
 public static Assign ReadData(Location loc, LineId line)
 {
     return new Assign(loc, readExpr, line);
 }
Пример #43
0
 public TypeCheckException(string message, LineId line, Exception innerException)
     : base(message, line, innerException)
 {
 }
Пример #44
0
 protected Expression(LineId line)
     : base(line)
 {
 }
Пример #45
0
 public Add(Expression e1, Expression e2, LineId line)
     : base(e1, e2, line)
 {
 }