private ActiveLeasesRepo1 CreateSUT(out LeaseDTO validSample) { var mkt = new Mock <IMarketStateDB>(); var moq = new Mock <ISimpleRepo <LeaseDTO> >(); var sut = new ActiveLeasesRepo1(moq.Object, mkt.Object); validSample = ValidSampleDTO(); moq.Setup(_ => _.Any()).Returns(true); moq.Setup(_ => _.Find(It.IsAny <int>(), true)).Returns(ValidSampleDTO()); moq.Setup(_ => _.GetAll()) .Returns(new List <LeaseDTO> { //new LeaseDTO { Stall = new StallDTO{ Id = OCCUPIED_BY_SAMPLE }}, new LeaseDTO { Stall = new StallDTO { Id = OCCUPIED_BY_ANOTHER } } }); return(sut); }
public void CallingDeletefails() { var arg = new MockMarketState(); var moq = new Mock <ISimpleRepo <LeaseDTO> >(); var sut = new ActiveLeasesRepo1(moq.Object, arg); var lse = new LeaseDTO(); arg.MoqInactiveLeases.Setup(_ => _.HasId(lse.Id)).Returns(false); sut.Invoking(_ => _.Delete(lse)) .Should().Throw <InvalidDeletionException>(); }
public void TestMethod() { var arg = new MockMarketState(); var moq = new Mock <ISimpleRepo <LeaseDTO> >(); var lse = new LeaseDTO(); var sut = new ActiveLeasesRepo1(moq.Object, arg); arg.MoqInactiveLeases.Setup(_ => _.HasId(lse.Id)).Returns(true); moq.Setup(_ => _.Delete(lse)).Returns(true); sut.Delete(lse).Should().BeTrue(); }
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); }