Esempio n. 1
0
        public void UpdateAcceptsnonnameedit()
        {
            var moq = new Mock <ISimpleRepo <SectionDTO> >();
            var sut = new SectionsRepo1(moq.Object, null);
            var rec = new SectionDTO {
                Id = 1, Name = "Sample 1"
            };

            moq.Setup(_ => _.GetAll())
            .Returns(new List <SectionDTO> {
                rec
            });

            rec.Name = rec.Name + " changed";
            sut.Update(rec);
        }
Esempio n. 2
0
        public void UpdateAcceptsUniquename()
        {
            var moq  = new Mock <ISimpleRepo <SectionDTO> >();
            var sut  = new SectionsRepo1(moq.Object, null);
            var rec1 = new SectionDTO {
                Id = 1, Name = "Sample 1"
            };
            var rec2a = new SectionDTO {
                Id = 2, Name = "Sample 2"
            };
            var rec2b = rec2a.ShallowClone <SectionDTO>();

            moq.Setup(_ => _.GetAll())
            .Returns(new List <SectionDTO> {
                rec1, rec2a
            });

            rec2b.Name = rec2a.Name + " changed";
            sut.Update(rec2b);
        }