Exemple #1
0
        public void it_should_pass_inspection_for_weekly_product()
        {
            var          inspectionId   = InspectionId.Create("inspection-identifier");
            LicencePlate licencePlate   = LicencePlate.Create("123-456");
            const string location       = "Kernow";
            var          inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero);
            var          stream         = new object[] {
                new VehicleRegistered(licencePlate.ToString()),
                // In the past
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(-57).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(-50).ToUnixTimeSeconds()),
                // Covers current inspection
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(-2).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(5).ToUnixTimeSeconds()),
                // In the future
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: inspectionTime.AddDays(1).ToUnixTimeSeconds(),
                    finish: inspectionTime.AddDays(8).ToUnixTimeSeconds())
            };
            var vehicle = Vehicle.FromStream(licencePlate, stream);

            vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location);

            DeepAssert.Equal(Array.Empty <object>(), vehicle.TakeChanges().ToArray());
        }
        public void It_should_book_unregistered_vehicle()
        {
            var vehicle = Vehicle.FromStream(LicencePlate.Create("123-123"));

            vehicle.Book(LicencePlate.Create("123-123"), "Kernow", 1579132800, EndOf.Day);

            var expected = new object[] {
                new VehicleRegistered(licencePlate: "123-123"),
                new VehicleBooked(
                    licencePlate: "123-123",
                    location: "Kernow",
                    start: new DateTimeOffset(new DateTime(2020, 01, 16)).ToUnixTimeSeconds(),
                    finish: new DateTimeOffset(new DateTime(2020, 01, 17)).AddSeconds(-1).ToUnixTimeSeconds()
                    )
            };

            DeepAssert.Equal(expected, vehicle.TakeChanges().ToArray());
            Assert.Equal(1, vehicle.Version);
        }
Exemple #3
0
        public void it_should_fail_inspection()
        {
            var          inspectionId   = InspectionId.Create("inspection-identifier");
            LicencePlate licencePlate   = LicencePlate.Create("123-456");
            const string location       = "Kernow";
            var          inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero);
            var          vehicle        = Vehicle.FromStream(licencePlate);

            vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location);

            var expected = new object[] {
                new VehicleRegistered(licencePlate: licencePlate.ToString()),
                new VehicleUnbooked(
                    inspectionId: inspectionId.ToString(),
                    licencePlate: licencePlate.ToString(),
                    location: location)
            };

            DeepAssert.Equal(expected, vehicle.TakeChanges().ToArray());
        }
Exemple #4
0
        public void it_should_pass_inspection_for_all_day_product()
        {
            var          inspectionId   = InspectionId.Create("inspection-identifier");
            LicencePlate licencePlate   = LicencePlate.Create("123-456");
            const string location       = "Kernow";
            var          inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero);
            var          stream         = new object[] {
                new VehicleRegistered(licencePlate.ToString()),
                // start at half-eight pm, ends one second before midnight.
                new VehicleBooked(
                    licencePlate: licencePlate.ToString(),
                    location: location,
                    start: 1581755400,                     // 02/15/2020 @ 8:30am (UTC)
                    finish: 1581811199)                    // 02/15/2020 @ 11:59pm (UTC)
            };
            var vehicle = Vehicle.FromStream(licencePlate, stream);

            vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location);

            DeepAssert.Equal(Array.Empty <object>(), vehicle.TakeChanges().ToArray());
        }