public void UpdateAcceptsUniquename() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var sut = new StallsRepo1(moq.Object, null); var rec1 = new StallDTO { Id = 1, Name = "Sample 1" }; var rec2a = new StallDTO { Id = 2, Name = "Sample 2" }; var rec2b = rec2a.ShallowClone <StallDTO>(); moq.Setup(_ => _.GetAll()) .Returns(new List <StallDTO> { rec1, rec2a }); rec2b.Name = rec2a.Name + " changed"; sut.Update(rec2b); }
public void UpdateRejectsduplicatestallname() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var sut = new StallsRepo1(moq.Object, null); var rec1 = new StallDTO { Id = 1, Name = "Sample 1" }; var rec2 = new StallDTO { Id = 2, Name = "Sample 2" }; var recX = rec2.ShallowClone <StallDTO>(); moq.Setup(_ => _.GetAll()) .Returns(new List <StallDTO> { rec1, rec2 }); recX.Name = rec1.Name; sut.Invoking(_ => _.Update(recX)) .Should().Throw <DuplicateRecordsException>(); }