public void RejectInactiveLeasetype() { var sut = new MockMarketState(); var lse = new InactiveLeaseDTO(); sut.Invoking(_ => _.DeactivateLease(lse, "", DateTime.Now)) .Should().Throw <InvalidStateException>(); }
public void ReturnsrecordwithsameId() { var sut = new MockMarketState(); var lse = new LeaseDTO { Id = 12345 }; var rec = sut.DeactivateLease(lse, "", DateTime.Now); rec.Should().NotBeNull(); rec.Id.Should().Be(lse.Id); }
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 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 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>(); }
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 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); }