Ejemplo n.º 1
0
 public PlotQueryResultDto(PlotEntity plotEntity)
 {
     this.EventCode = plotEntity.EventCode.ToString();
     this.Lat       = plotEntity.Lat;
     this.Lon       = plotEntity.Lon;
     this.VId       = plotEntity.VId;
     this.TimeStamp = plotEntity.TimeStamp;
 }
Ejemplo n.º 2
0
        public Task <bool> Add(PlotEntity plotEntity)
        {
            var key = this.GetKey(plotEntity);

            base.Add(key, plotEntity);
            this.numPlots++;
            return(Task.FromResult(true));
        }
Ejemplo n.º 3
0
        public void RegisterMovementSuccess()
        {
            var entity = new PlotEntity(Vehicleid, 11, 11, DateTime.Now, EventCode.Movement);

            this.plotAppService.Register(entity);

            this.emitter.Received(1).Emit(Arg.Any <RegisterPlotEvent>());
        }
Ejemplo n.º 4
0
        private PlotEntity GeneratePlot(int vehicleId, EventCode eventCode)
        {
            var plotEntity = new PlotEntity(vehicleId, this.coordinates, this.coordinates, DateTime.Now, eventCode);

            this.coordinates++;

            return(plotEntity);
        }
Ejemplo n.º 5
0
        public void RegisterIgnitionOnSuccess()
        {
            var entity = new PlotEntity(Vehicleid, 10, 10, DateTime.Now, EventCode.IgnitionOn);

            this.plotAppService.Register(entity);

            this.emitter.Received(1).Emit(Arg.Any <RegisterPlotEvent>());
        }
Ejemplo n.º 6
0
        public Task Register(PlotEntity plotEntity)
        {
            this.logger.LogTrace("Registering Event");

            this.eventEmitter.Emit(new RegisterPlotEvent(plotEntity));

            this.logger.LogTrace("Registered Event");

            return(Task.CompletedTask);
        }
Ejemplo n.º 7
0
        public async Task CreateFirstEventSuccess()
        {
            PlotEntity plotEntity = null;

            this.plotAppService.When(method => method.Register(Arg.Any<PlotEntity>())).Do(args => plotEntity = (PlotEntity)args[0]);

            await this.senderService.GenerateRandomPlot(Vehicleid);

            Assert.NotNull(plotEntity);
            Assert.Equal(EventCode.IgnitionOn, plotEntity.EventCode);
        }
Ejemplo n.º 8
0
        private PlotQueryResultDto PlotEntityToPlotQueryResultDto(PlotEntity plotEntity, ref DateTime?lastIgnitionOn)
        {
            var result = new PlotQueryResultDto(plotEntity);

            switch (plotEntity.EventCode)
            {
            case EventCode.IgnitionOn:
                result.JourneyStart = plotEntity.TimeStamp;
                lastIgnitionOn      = plotEntity.TimeStamp;
                break;

            case EventCode.IgnitionOff:
                result.JourneyStart = lastIgnitionOn;
                result.JourneyEnd   = plotEntity.TimeStamp;
                lastIgnitionOn      = null;
                break;

            case EventCode.Movement:
                result.JourneyStart = lastIgnitionOn;
                break;
            }

            return(result);
        }
Ejemplo n.º 9
0
 private async Task <bool> EventMovementReceived(PlotEntity entity)
 {
     return(await this.plotRepository.Add(entity));
 }
Ejemplo n.º 10
0
 private async Task <bool> EventIgnitionOnReceived(PlotEntity entity)
 {
     return
         (await this.plotRepository.AddIgnitionOn(entity.VId, entity.TimeStamp) &&
          await this.plotRepository.Add(entity));
 }
Ejemplo n.º 11
0
 public RegisterPlotEvent(PlotEntity entity)
 {
     this.Entity = entity;
 }
Ejemplo n.º 12
0
 private string GetKey(PlotEntity plotEntity)
 {
     return(this.GetKey(plotEntity.VId, plotEntity.TimeStamp));
 }
Ejemplo n.º 13
0
 private string GetKey(PlotEntity plotEntity)
 {
     return(this.GetKey(plotEntity.VId));
 }
Ejemplo n.º 14
0
        public async Task <bool> Add(PlotEntity plotEntity)
        {
            var key = this.GetKey(plotEntity);

            return(await this.redis.AddSet(key, plotEntity, plotEntity.TimeStamp.ToOADate()));
        }