public async Task ShouldAssignNothingAndReturnReservationId() { //Arrange var context = new iReceptionDbContext(DbOptions); var repository = new MinuteServiceToReservationRepository(context, null); var convertedMinuteServiceToReservation = new MinuteServiceToReservation { ReservationId = 1, MinuteServiceId = 0, Duration = 30 }; //Act var actual = await repository.AddAsync(convertedMinuteServiceToReservation); var expected = convertedMinuteServiceToReservation.ReservationId; //Assert Assert.Equal(expected, actual); }
public async Task ShouldAssignServiceToReservation() { //Arrange var context = new iReceptionDbContext(DbOptions); var returnedMinuteService = new MinuteService { Id = 1, PricePerMinute = 10 }; var msRepository = new Mock <IMinuteServiceRepository>(); msRepository .Setup(r => r.GetAsync(It.IsAny <int>())) .ReturnsAsync(returnedMinuteService); var repository = new MinuteServiceToReservationRepository(context, msRepository.Object); var convertedMinuteServiceToReservation = new MinuteServiceToReservation { ReservationId = 1, MinuteServiceId = 12, Duration = 30 }; //Act var actual = await repository.AddAsync(convertedMinuteServiceToReservation); var expected = convertedMinuteServiceToReservation.MinuteServiceId; var actualCost = (await context.MinuteServicesToReservation.FirstAsync( mstr => mstr.MinuteServiceId == 12)).Cost; var expectedCost = convertedMinuteServiceToReservation.Duration * returnedMinuteService.PricePerMinute; //Assert Assert.Equal(expected, actual); Assert.Equal(expectedCost, actualCost); }