Exemplo n.º 1
0
        public async Task GetDetailsAsync_SouldReturn_DetaildInformation_IfEntityExist()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();
            var client = new Client {
                Id = 1, Name = "Margaritka 89"
            };
            await db.Clients.AddAsync(client);

            var property = new Property {
                Id = 1, Area = 2000, Name = "Warehouse"
            };
            await db.Properties.AddAsync(property);

            var firstRent = new RentAgreement
            {
                Id                     = 1,
                Description            = "Some",
                ParkingSlotDescription = "None",
                MonthlyPrice           = 2000,
                StartDate              = new DateTime(2018, 3, 3),
                Client                 = client,
                PropertyRents          = new List <PropertyRent>()
                {
                    new PropertyRent {
                        Property = property
                    }
                }
            };
            await db.RentAgreements.AddAsync(firstRent);

            await db.SaveChangesAsync();

            var rentService = new RentsService(mapper, db, null);

            var result = await rentService.GetDetailsAsync(1);

            result
            .Should()
            .BeOfType <RentDetailsModel>()
            .And
            .Match <RentDetailsModel>(r =>
                                      r.Client == "Margaritka 89" &&
                                      r.Description == "Some" &&
                                      r.EndDate == null &&
                                      r.MonthlyPrice == 2000 &&
                                      r.ParkingSlotDescription == "None" &&
                                      r.Properties.Any(x => x.Area == 2000) &&
                                      r.StartDate == new DateTime(2018, 3, 3)
                                      );
        }
Exemplo n.º 2
0
        public async Task GetDetailsAsync_SouldReturn_Null_IfEntityDoNotExist()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();
            var client = new Client {
                Id = 1, Name = "Margaritka 89"
            };
            await db.Clients.AddAsync(client);

            var property = new Property {
                Id = 1, Area = 2000, Name = "Warehouse"
            };
            await db.Properties.AddAsync(property);

            var firstRent = new RentAgreement
            {
                Id                     = 1,
                Description            = "Some",
                ParkingSlotDescription = "None",
                MonthlyPrice           = 2000,
                StartDate              = new DateTime(2018, 3, 3),
                Client                 = client,
                PropertyRents          = new List <PropertyRent>()
                {
                    new PropertyRent {
                        Property = property
                    }
                }
            };
            await db.RentAgreements.AddAsync(firstRent);

            await db.SaveChangesAsync();

            var rentService = new RentsService(mapper, db, null);

            var result = await rentService.GetDetailsAsync(2);

            result
            .Should()
            .BeNull();
        }