public async Task RecognizeCorrectSpeedViolation() { var now = DateTime.UtcNow; var inMemoryStorage = new InMemoryStorage(); var car = new Car { Nationality = "A", LicensePlate = "X", ActiveSection = new Enter { StartCameraID = "1", Timestamp = now.AddHours(-1d).Ticks } }; var camera = new Camera { ID = "2", End = new EndCamera { StartCameraID = "1", DistanceFromStart = 100000, MaximumAverageSpeed = 100 } }; await inMemoryStorage.CreateCarAsync(car); await inMemoryStorage.CreateCameraAsync(camera); await CheckSectionControl.Run( new PlateRead { CameraID = "2", Nationality = "A", LicensePlate = "X", ReadTimestamp = now.Ticks }, new DebugLogger(""), inMemoryStorage); Assert.Empty(car.Violations); Assert.Null(car.ActiveSection); Assert.Equal(1, inMemoryStorage.NumberOfCarUpdates); }
public async Task RecognizeMissingVignette() { var inMemoryStorage = new InMemoryStorage(); var car = new Car { LicensePlate = "X" }; await inMemoryStorage.CreateCarAsync(car); await CheckVignette.Run(new PlateRead { LicensePlate = "X" }, new DebugLogger(""), inMemoryStorage); Assert.NotEmpty(car.Violations); }
public async Task RecognizeExitWithoutEntry() { var inMemoryStorage = new InMemoryStorage(); var car = new Car { Nationality = "A", LicensePlate = "X" }; var camera = new Camera { ID = "1", End = new EndCamera() }; await inMemoryStorage.CreateCarAsync(car); await inMemoryStorage.CreateCameraAsync(camera); await CheckSectionControl.Run( new PlateRead { CameraID = "1", Nationality = "A", LicensePlate = "X" }, new DebugLogger(""), inMemoryStorage); Assert.NotEmpty(car.Violations); Assert.Equal(1, inMemoryStorage.NumberOfCarUpdates); }
public async Task StoresActiveSessionOnEnter() { var inMemoryStorage = new InMemoryStorage(); var car = new Car { Nationality = "A", LicensePlate = "X" }; var camera = new Camera { ID = "1", Start = new StartCamera() }; await inMemoryStorage.CreateCarAsync(car); await inMemoryStorage.CreateCameraAsync(camera); await CheckSectionControl.Run( new PlateRead { CameraID = "1", Nationality = "A", LicensePlate = "X" }, new DebugLogger(""), inMemoryStorage); Assert.Empty(car.Violations); Assert.NotNull(car.ActiveSection); Assert.Equal(1, inMemoryStorage.NumberOfCarUpdates); }
public async Task DetectValidVignette() { var inMemoryStorage = new InMemoryStorage(); var car = new Car { LicensePlate = "X", Vignettes = new List <Vignette> { new Vignette { From = DateTime.UtcNow.AddMinutes(-5).Ticks, Until = DateTime.UtcNow.AddMinutes(5).Ticks } } }; await inMemoryStorage.CreateCarAsync(car); await CheckVignette.Run( new PlateRead { LicensePlate = "X", ReadTimestamp = DateTime.UtcNow.Ticks }, new DebugLogger(""), inMemoryStorage); Assert.Empty(car.Violations); }