public async Task EditAsync_ShouldReturn_false_IfRentAlreadyPaid() { var db = GetDatabase(); var mapper = GetMapper(); var firstRent = new MonthlyPaymentRent { Id = 1, DeadLine = new DateTime(2018, 12, 12), TotalPayment = 200, IsPaid = true }; var secndRent = new MonthlyPaymentRent { Id = 2, DeadLine = new DateTime(2017, 11, 6), TotalPayment = 300, IsPaid = true }; await db.MonthlyPaymentRents.AddRangeAsync(firstRent, secndRent); await db.SaveChangesAsync(); var rentPaymentService = new MonthlyRentsService(mapper, db); //Act var editModel = new MonthlyRentViewModel { Id = 4, DeadLine = new DateTime(2018, 12, 22), TotalPayment = 300 }; var result = await rentPaymentService.EditAsync(editModel); ; //Assert result .Should() .BeFalse(); }
public async Task EditAsync_ShouldReturn_True_IfRentExist() { var db = GetDatabase(); var mapper = GetMapper(); var firstRent = new MonthlyPaymentRent { Id = 1, DeadLine = new DateTime(2018, 12, 12), TotalPayment = 200, IsPaid = false }; var secndRent = new MonthlyPaymentRent { Id = 2, DeadLine = new DateTime(2017, 11, 6), TotalPayment = 300, IsPaid = false }; await db.MonthlyPaymentRents.AddRangeAsync(firstRent, secndRent); await db.SaveChangesAsync(); var rentPaymentService = new MonthlyRentsService(mapper, db); //Act var editModel = new MonthlyRentViewModel { Id = 1, DeadLine = new DateTime(2018, 12, 22), TotalPayment = 300 }; var result = await rentPaymentService.EditAsync(editModel); var createdRent = await db.MonthlyPaymentRents .FirstOrDefaultAsync(x => x.Id == 1); //Assert result .Should() .BeTrue(); createdRent .Should() .Match <MonthlyPaymentRent>(x => x.TotalPayment == 300 && x.DeadLine == new DateTime(2018, 12, 22)); }