public void NonActiveInsertFails()
        {
            var arg = new MockMarketState();
            var moq = new Mock <ISimpleRepo <InactiveLeaseDTO> >();
            var sut = new InactiveLeasesRepo1(moq.Object, arg);
            var lse = new InactiveLeaseDTO();

            arg.MoqActiveLeases.Setup(_
                                      => _.HasId(lse.Id)).Returns(false);

            sut.Invoking(_ => _.Insert(lse))
            .Should().Throw <InvalidInsertionException>();
        }
        public void ErrorifrecordundeletedforActives()
        {
            var arg = new MockMarketState();
            var moq = new Mock <ISimpleRepo <InactiveLeaseDTO> >();
            var sut = new InactiveLeasesRepo1(moq.Object, arg);
            var lse = new InactiveLeaseDTO {
                Id = 1234
            };

            arg.MoqActiveLeases.SetupSequence(_
                                              => _.HasId(lse.Id)).Returns(true)
            .Returns(true);

            sut.Invoking(_ => _.Insert(lse))
            .Should().Throw <InvalidStateException>();
        }
Esempio 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);
        }
        public void InsertcallsBatchBalUpdateafterSave()
        {
            var arg = new MockMarketState();
            var moq = new Mock <ISimpleRepo <InactiveLeaseDTO> >();
            var bal = new Mock <IDailyBillsRepo>();
            var sut = new InactiveLeasesRepo1(moq.Object, arg);
            var lse = new InactiveLeaseDTO {
                Id = 1234
            };

            arg.MoqActiveLeases.SetupSequence(_
                                              => _.HasId(lse.Id)).Returns(true)
            .Returns(false);
            arg.MoqBalanceDB.Setup(_
                                   => _.GetRepo(lse.Id)).Returns(bal.Object);

            sut.Insert(lse);

            bal.Verify(_ => _
                       .RecomputeFrom(lse.DeactivatedDate), Times.Once);
        }
        public void InsertremovesfromActivesafterSave()
        {
            var arg = new MockMarketState();
            var moq = new Mock <ISimpleRepo <InactiveLeaseDTO> >();
            var sut = new InactiveLeasesRepo1(moq.Object, arg);
            var lse = new InactiveLeaseDTO {
                Id = 1234
            };

            arg.MoqActiveLeases.SetupSequence(_
                                              => _.HasId(lse.Id)).Returns(true)
            .Returns(false);

            arg.MoqBalanceDB.Setup(_ => _.GetRepo(lse.Id))
            .Returns(Mock.Of <IDailyBillsRepo>());

            sut.Insert(lse);

            arg.MoqActiveLeases.Verify(_
                                       => _.Delete(lse.Id), Times.Once());
        }
        public void ActiveInsertionreturnsrecwithsameID()
        {
            var arg = new MockMarketState();
            var moq = new Mock <ISimpleRepo <InactiveLeaseDTO> >();
            var sut = new InactiveLeasesRepo1(moq.Object, arg);
            var lse = new InactiveLeaseDTO {
                Id = 1234
            };

            arg.MoqActiveLeases.SetupSequence(_
                                              => _.HasId(lse.Id)).Returns(true)
            .Returns(false);

            arg.MoqBalanceDB.Setup(_ => _.GetRepo(lse.Id))
            .Returns(Mock.Of <IDailyBillsRepo>());

            moq.Setup(_ => _.Insert(lse)).Returns(lse.Id);

            var rId = sut.Insert(lse);

            rId.Should().Be(lse.Id);
        }