示例#1
0
        public async Task GetDetailsAsync_ShouldReturn_CorrectModel_IfRentAgreementExistInDb()
        {
            var db                 = GetDatabase();
            var mapper             = GetMapper();
            var firstRentAgreement = new RentAgreement
            {
                Id            = 1,
                MonthlyPrice  = 1000,
                PropertyRents = new List <PropertyRent>
                {
                    new PropertyRent
                    {
                        Property = new Property {
                            Id = 1, Name = "Room", Area = 10, IsActual = true
                        }
                    }
                },
                Client = new Client {
                    Id = 1, Name = "Petar"
                },
                ParkingSlots = new List <ParkingSlot>
                {
                    new ParkingSlot {
                        Id = 1, Quantity = 10, Price = 10
                    },
                    new ParkingSlot {
                        Id = 2, Quantity = 2, Price = 2
                    }
                }
            };

            await db.RentAgreements.AddAsync(firstRentAgreement);

            await db.SaveChangesAsync();

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

            //Assert
            result
            .Should()
            .Match <CreateMonthlyRentFormViewModel>(x =>
                                                    x.Client == "Petar" &&
                                                    x.ParkingSlotsQty == 12 &&
                                                    x.Properties.Contains("Room с площ: 10") &&
                                                    x.TotalPayment == 1104 &&
                                                    x.RentAgreementId == 1);
        }
示例#2
0
        public async Task GetDetailsAsync_ShouldReturn_Null_IfRentAgreementDoNotExistInDb()
        {
            var db                 = GetDatabase();
            var mapper             = GetMapper();
            var firstRentAgreement = new RentAgreement
            {
                Id            = 1,
                MonthlyPrice  = 1000,
                PropertyRents = new List <PropertyRent>
                {
                    new PropertyRent
                    {
                        Property = new Property {
                            Id = 1, Name = "Room", Area = 10, IsActual = true
                        }
                    }
                },
                Client = new Client {
                    Id = 1, Name = "Petar"
                },
                ParkingSlots = new List <ParkingSlot>
                {
                    new ParkingSlot {
                        Id = 1, Quantity = 10, Price = 10
                    },
                    new ParkingSlot {
                        Id = 2, Quantity = 2, Price = 2
                    }
                }
            };

            await db.RentAgreements.AddAsync(firstRentAgreement);

            await db.SaveChangesAsync();

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

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