Beispiel #1
0
        public void CreateSchedule()
        {
            var booking = new BlackMaple.CSVOrders.CSVBookings();

            var schParts = new ScheduledPartWithoutBooking[] {
                new ScheduledPartWithoutBooking {
                    Part = "part1", Quantity = 12
                },
                new ScheduledPartWithoutBooking {
                    Part = "part2", Quantity = 52
                },
                new ScheduledPartWithoutBooking {
                    Part = "part4", Quantity = 9876
                }
            };

            var downParts = new DownloadedPart[] {
                new DownloadedPart {
                    ScheduleId = "12345", Part = "part1", Quantity = 155
                },
                new DownloadedPart {
                    ScheduleId = "12345", Part = "part2", Quantity = 166
                }
            };

            booking.CreateSchedule(
                new NewSchedule
            {
                ScheduleId       = "12345",
                ScheduledTimeUTC = new DateTime(2016, 11, 05),
                ScheduledHorizon = TimeSpan.FromMinutes(155),
                BookingIds       = new List <string>()
                {
                    "booking1", "booking2"
                },
                DownloadedParts = downParts.ToList(),
                ScheduledParts  = schParts.ToList()
            });

            //check status
            booking.LoadScheduledParts().Should().BeEquivalentTo(schParts);
            booking.LoadUnscheduledBookings(50).Values.Should().BeEquivalentTo(
                new Booking[] { initialBookings[2] }
                );
            Assert.Null(booking.LoadLatestBackoutId());

            var sch1 = File.ReadAllLines("scheduled-bookings/booking1.csv");
            var sch2 = File.ReadAllLines("scheduled-bookings/booking2.csv");

            sch1.Should().BeEquivalentTo(new string[] {
                "ScheduledTimeUTC,Part,Quantity,ScheduleId",
                "2016-11-05T00:00:00Z,part1,44,12345",
                "2016-11-05T00:00:00Z,part2,66,12345"
            });
            sch2.Should().BeEquivalentTo(new string[] {
                "ScheduledTimeUTC,Part,Quantity,ScheduleId",
                "2016-11-05T00:00:00Z,part1,55,12345",
                "2016-11-05T00:00:00Z,part2,77,12345"
            });
        }
Beispiel #2
0
        public void CreateSchedule()
        {
            var booking = new ExampleOrderIntegration.ExampleBookingDatabase();

            var schParts = new ScheduledPartWithoutBooking[] {
                new ScheduledPartWithoutBooking {
                    Part = "part1", Quantity = 12
                },
                new ScheduledPartWithoutBooking {
                    Part = "part2", Quantity = 52
                },
                new ScheduledPartWithoutBooking {
                    Part = "part4", Quantity = 9876
                }
            };

            var downParts = new DownloadedPart[] {
                new DownloadedPart {
                    ScheduleId = "12345", Part = "part1", Quantity = 155
                },
                new DownloadedPart {
                    ScheduleId = "12345", Part = "part2", Quantity = 166
                }
            };

            booking.CreateSchedule(
                new NewSchedule
            {
                ScheduleId       = "12345",
                ScheduledTimeUTC = new DateTime(2016, 11, 05),
                ScheduledHorizon = TimeSpan.FromMinutes(155),
                BookingIds       = new List <string> {
                    "booking1", "booking2"
                },
                DownloadedParts = downParts.ToList(),
                ScheduledParts  = schParts.ToList()
            });

            using (var ctx = new ExampleOrderIntegration.BookingContext())
            {
                Assert.Equal(
                    ctx.Bookings.Single(b => b.BookingId == "booking1").ScheduleId,
                    "12345"
                    );
                Assert.Equal(
                    ctx.Bookings.Single(b => b.BookingId == "booking1").ScheduleId,
                    "12345"
                    );

                ctx.ExtraParts.ToList().ShouldAllBeEquivalentTo(schParts);
            }

            //check status
            var status = booking.LoadUnscheduledStatus(50);

            status.ScheduledParts.ShouldAllBeEquivalentTo(schParts);
            status.UnscheduledBookings.ShouldAllBeEquivalentTo(
                new Booking[] { initialBookings[2] }
                );
            Assert.Null(status.LatestBackoutId);

            initialBookings[0].ScheduleId = "12345";
            initialBookings[1].ScheduleId = "12345";

            LoadScheduledBookings().ShouldAllBeEquivalentTo(
                new Booking[] { initialBookings[0], initialBookings[1] }
                );
        }