public void InsertRejectsduplicatestallname() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var sut = new StallsRepo1(moq.Object, null); var stall = StallDTO.Named("sample"); moq.Setup(_ => _.GetAll()) .Returns(new List <StallDTO> { stall }); sut.Invoking(_ => _.Insert(stall)) .Should().Throw <DuplicateRecordsException>(); }
public void UpdateAcceptsnonnameedit() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var sut = new StallsRepo1(moq.Object, null); var rec = new StallDTO { Id = 1, Name = "Sample 1" }; moq.Setup(_ => _.GetAll()) .Returns(new List <StallDTO> { rec }); rec.Name = rec.Name + " changed"; sut.Update(rec); }
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); }
public void CantDeleteifOccupied() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var db = new MockMarketState(); var sut = new StallsRepo1(moq.Object, db); var stall = StallDTO.Named("sample"); db.MoqActiveLeases.Setup(_ => _.GetAll()) .Returns(new List <LeaseDTO> { new LeaseDTO { Stall = stall } }); sut.Invoking(_ => _.Delete(stall)).Should() .Throw <InvalidDeletionException>(); }
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 Allowsduplicatenamediffsection() { var moq = new Mock <ISimpleRepo <StallDTO> >(); var sut = new StallsRepo1(moq.Object, null); var rec1_1 = new StallDTO { Id = 1, Name = "Sample 1", Section = new SectionDTO { Id = 1 } }; var rec1_2 = new StallDTO { Id = 2, Name = "Sample 2", Section = new SectionDTO { Id = 1 } }; var rec2_1 = new StallDTO { Id = 3, Name = "Sample 1", Section = new SectionDTO { Id = 2 } }; moq.Setup(_ => _.GetAll()) .Returns(new List <StallDTO> { rec1_1, rec1_2, rec2_1 }); rec2_1.Remarks = "edit"; sut.Update(rec2_1); }
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>(); }