Exemplo n.º 1
0
        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>();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public MarketStateDBFile(string marketDbFilePath, string currentUser)
        {
            _mktDbPath   = marketDbFilePath;
            _currUsr     = currentUser;
            DatabasePath = marketDbFilePath;
            CurrentUser  = currentUser;
            var mktDb = new SharedLiteDB(_mktDbPath, _currUsr);

            Stalls         = new StallsRepo1(new StallsCollection(mktDb), this);
            Collectors     = new CollectorsRepo1(new CollectorsCollection(mktDb), this);
            BankAccounts   = new BankAccountsRepo1(new BankAccountsCollection(mktDb), this);
            Sections       = new SectionsRepo1(new SectionsCollection(mktDb), this);
            ActiveLeases   = new ActiveLeasesRepo1(new ActiveLeasesCollection(mktDb), this);
            InactiveLeases = new InactiveLeasesRepo1(new InactiveLeasesCollection(mktDb), this);
            CacheMetadataFields(mktDb);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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>();
        }