Esempio n. 1
0
        public async Task GetByIdAsync_ShouldReturn_CorrectModel_IfRentExistInDb()
        {
            var db        = GetDatabase();
            var mapper    = GetMapper();
            var firstRent = new MonthlyPaymentRent {
                Id = 1, DeadLine = new DateTime(2018, 12, 12), TotalPayment = 200, IsPaid = false, ApplyVAT = true
            };
            var secndRent = new MonthlyPaymentRent {
                Id = 2, DeadLine = new DateTime(2017, 11, 6), TotalPayment = 300, IsPaid = false, ApplyVAT = true
            };
            await db.MonthlyPaymentRents.AddRangeAsync(firstRent, secndRent);

            await db.SaveChangesAsync();

            var rentPaymentService = new MonthlyRentsService(mapper, db);
            //Act
            var result = await rentPaymentService.GetByIdAsync(1);

            //Assert
            result
            .Should()
            .BeOfType <MonthlyRentViewModel>()
            .And
            .Match <MonthlyRentViewModel>(x =>
                                          x.TotalPayment == 200 &&
                                          x.DeadLine == new DateTime(2018, 12, 12));
        }
Esempio n. 2
0
        public async Task GetByIdAsync_ShouldReturn_Nulll_IfRentDoNotExistInDb()
        {
            var db        = GetDatabase();
            var mapper    = GetMapper();
            var firstRent = new MonthlyPaymentRent {
                Id = 1, DeadLine = new DateTime(2018, 12, 12), TotalPayment = 200, IsPaid = false, ApplyVAT = true
            };
            var secndRent = new MonthlyPaymentRent {
                Id = 2, DeadLine = new DateTime(2017, 11, 6), TotalPayment = 300, IsPaid = false, ApplyVAT = true
            };
            await db.MonthlyPaymentRents.AddRangeAsync(firstRent, secndRent);

            await db.SaveChangesAsync();

            var rentPaymentService = new MonthlyRentsService(mapper, db);
            //Act
            var result = await rentPaymentService.GetByIdAsync(3);

            //Assert
            result
            .Should()
            .BeNull();
        }