public static async Task <TestData> Init(RepositoryFixture fixture, IClock mockTime) { var data = new TestData(fixture, mockTime) { Reservation1 = await fixture.Reservations.CreateNewReservation( mockTime.GetCurrentInstant().Plus(Duration.FromHours(10)), mockTime.GetCurrentInstant().Plus(Duration.FromHours(12)), await fixture.Resources.FindById(1), await fixture.Users.FindById(1), true ), Reservation2 = await fixture.Reservations.CreateNewReservation( mockTime.GetCurrentInstant().Plus(Duration.FromHours(15)), mockTime.GetCurrentInstant().Plus(Duration.FromHours(17)), await fixture.Resources.FindById(1), await fixture.Users.FindById(1), true ), Reservation3 = await fixture.Reservations.CreateNewReservation( mockTime.GetCurrentInstant().Plus(Duration.FromHours(10)), mockTime.GetCurrentInstant().Plus(Duration.FromHours(17)), await fixture.Resources.FindById(2), await fixture.Users.FindById(2), true ) }; // resource 1 form 15 to +17 hours // resource 2 (user 2) form 10 to +17 hours data.Reservation3.StatusChanges = new List <StatusChange> { new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(1)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(1), ChangedBy = null }, new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(2)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(3), ChangedBy = null }, }; data.Reservation2.StatusChanges = new List <StatusChange> { new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(1)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(2), ChangedBy = null }, new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(2)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(4), ChangedBy = null }, new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(3)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(2), ChangedBy = null }, }; data.Reservation1.StatusChanges = new List <StatusChange> { new StatusChange { ChangedAt = mockTime.GetCurrentInstant().Plus(Duration.FromHours(1)), Reason = "changed", PreviousStatus = null, CurrentStatus = await fixture.ReservationStatuses.ById(1), ChangedBy = null }, }; data._fixture.Database.Ctx.SaveChanges(); return(data); }
private TestData(RepositoryFixture fixture, IClock mockTime) { _fixture = fixture; }