public void Delete_A_Section() { // Arrange SectionService _sectionService = new SectionService(); List <Section> sections = new List <Section>(); Guid childrens_guid = Guid.NewGuid(); Guid teens_guid = Guid.NewGuid(); Guid adults_guid = Guid.NewGuid(); Section childrens_section = new Section { Id = childrens_guid, Code = "CHLD", Name = "Children", Description = "Children Aged 0-12" }; Section teens_section = new Section { Id = teens_guid, Code = "TEEN", Name = "Teenage", Description = "Children Aged 13-15" }; Section adults_section = new Section { Id = adults_guid, Code = "ADLT", Name = "Adult", Description = "Adults Aged 16+" }; _sectionService.Add(childrens_section, sections); _sectionService.Add(teens_section, sections); _sectionService.Add(adults_section, sections); // Act bool result = _sectionService.Delete(adults_guid, sections); // Assert Assert.AreEqual(2, sections.Count); CollectionAssert.DoesNotContain(sections, adults_section); }
//单个板块及其下房屋信息删除(先根据板块id删除所有该板块下房屋信息再通过sid删除该板块) protected void deleteSection() { sid = Int32.Parse(Request["sid"]); //先判断当前板块下是否存在房屋,存在则删除否则直接删除板块 if (houseService.GetRecordCount("sid= " + sid) > 0) { if (houseService.DeleteBySid(sid)) { if (sectionService.Delete(sid)) { Response.Write(true); Response.End(); } else { Response.Write(false); Response.End(); } } else { Response.Write(false); Response.End(); } } else { if (sectionService.Delete(sid)) { Response.Write(true); Response.End(); } else { Response.Write(false); Response.End(); } } }