public void InsertRejectsduplicateSectionname() { var moq = new Mock <ISimpleRepo <SectionDTO> >(); var sut = new SectionsRepo1(moq.Object, null); var sec = SectionDTO.Named("sample"); moq.Setup(_ => _.GetAll()) .Returns(new List <SectionDTO> { sec }); sut.Invoking(_ => _.Insert(sec)) .Should().Throw <DuplicateRecordsException>(); }
public void UpdateRejectsduplicatestallname() { var moq = new Mock <ISimpleRepo <SectionDTO> >(); var sut = new SectionsRepo1(moq.Object, null); var rec1 = new SectionDTO { Id = 1, Name = "Sample 1" }; var rec2 = new SectionDTO { Id = 2, Name = "Sample 2" }; var recX = rec2.ShallowClone <SectionDTO>(); moq.Setup(_ => _.GetAll()) .Returns(new List <SectionDTO> { rec1, rec2 }); recX.Name = rec1.Name; sut.Invoking(_ => _.Update(recX)) .Should().Throw <DuplicateRecordsException>(); }