コード例 #1
0
        public async Task EditDescriptionAsync_SouldReturn_False_IfInputIsNotCorrect()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();

            var firstRent = new RentAgreement {
                Id = 1, Description = "Some", ParkingSlotDescription = "None"
            };

            await db.RentAgreements.AddAsync(firstRent);

            await db.SaveChangesAsync();

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

            var result = await rentService.EditDescriptionsAsync("Property Description", "Parking description", 2);

            var editedRent = await db.RentAgreements.FindAsync(2);

            result
            .Should()
            .BeFalse();
            editedRent
            .Should()
            .BeNull();
        }
コード例 #2
0
        public async Task EditDescriptionAsync_SouldReturn_True_IfInputIsCorrect()
        {
            var db     = this.GetDatabase();
            var mapper = this.GetMapper();

            var firstRent = new RentAgreement {
                Id = 1, Description = "Some", ParkingSlotDescription = "None"
            };

            await db.RentAgreements.AddAsync(firstRent);

            await db.SaveChangesAsync();

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

            var result = await rentService.EditDescriptionsAsync("Property Description", "Parking description", 1);

            var editedRent = await db.RentAgreements.FindAsync(1);

            result
            .Should()
            .BeTrue();
            editedRent
            .Should()
            .BeOfType <RentAgreement>()
            .And
            .Match <RentAgreement>(c =>
                                   c.ParkingSlotDescription == "Parking description" &&
                                   c.Description == "Property Description");
        }