public void GetTAGByRevenueObjectId_CallsRepository_ValidRecordIsReturnedFromRepository_RecordIsReturned() { var beginEffectiveDate = DateTime.Today; var tag = new Repository.Models.V1.TAG { Id = 999 }; var moqRepository = new Mock <IRevenueObjectRepository>(); var marketAndRestrictedValue = new List <Repository.Models.V1.MarketAndRestrictedValue> { new Repository.Models.V1.MarketAndRestrictedValue { SubComponent = 123, MarketValue = 9999, RestrictedValue = 999 } }; moqRepository.Setup(x => x.GetTAGByRevenueObjectId(999, beginEffectiveDate)).Returns(tag); var moqMarketAndRestrictedRepository = new Mock <IMarketAndRestrictedValueRepository>(); moqMarketAndRestrictedRepository.Setup(x => x.Get(It.IsAny <int>(), It.IsAny <DateTime>())).Returns(marketAndRestrictedValue); var revenueObjectDomain = new RevenueObjectDomain(moqRepository.Object, moqMarketAndRestrictedRepository.Object); var returnTag = revenueObjectDomain.GetTAGByRevenueObjectId(999, beginEffectiveDate); returnTag.Id.ShouldBe(tag.Id); }
public void GetTAGByRevenueObjectId_CallsRepository_InvalidIdIsPassedToRepository_BadRequestExceptionIsThrown() { var tag = new Repository.Models.V1.TAG(); var marketAndRestrictedValue = new List <Repository.Models.V1.MarketAndRestrictedValue> { new Repository.Models.V1.MarketAndRestrictedValue { SubComponent = 123, MarketValue = 9999, RestrictedValue = 999 } }; var moqRepository = new Mock <IRevenueObjectRepository>(); moqRepository.Setup(x => x.GetTAGByRevenueObjectId(999, DateTime.Today)).Returns(tag); var moqMarketAndRestrictedRepository = new Mock <IMarketAndRestrictedValueRepository>(); moqMarketAndRestrictedRepository.Setup(x => x.Get(It.IsAny <int>(), It.IsAny <DateTime>())).Returns(marketAndRestrictedValue); var revenueObjectDomain = new RevenueObjectDomain(moqRepository.Object, moqMarketAndRestrictedRepository.Object); Should.Throw <BadRequestException>( () => revenueObjectDomain.GetTAGByRevenueObjectId(0, DateTime.Today)); }