public void Get_CallsRepository_ValidRecordIsReturnedFromRepository_RecordIsReturned() { var revenueObject = new Repository.Models.V1.RevenueObject { Id = 999 }; 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.Get(999, DateTime.Today)).Returns(revenueObject); 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 returnAssesmentEvent = revenueObjectDomain.Get(999, DateTime.Today); returnAssesmentEvent.Id.ShouldBe(revenueObject.Id); }
public void Get_CallsRepository_InValidIdIsPassedToRepository_MarketAndRestrictedValuesReturnsNull() { var revenueObject = new Repository.Models.V1.RevenueObject(); IList <Repository.Models.V1.MarketAndRestrictedValue> marketAndRestrictedValue = null; var moqRepository = new Mock <IRevenueObjectRepository>(); moqRepository.Setup(x => x.Get(999, DateTime.Today)).Returns(revenueObject); 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 returnAssessmentEvent = revenueObjectDomain.Get(999, DateTime.Today); returnAssessmentEvent.Id.ShouldBe(revenueObject.Id); returnAssessmentEvent.MarketAndRestrictedValues.ShouldBeNull(); }
public void Get_CallsRepository_InvalidIdIsPassedToRepository_BadRequestExceptionIsThrown() { var revenueObject = new Repository.Models.V1.RevenueObject(); 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.Get(999, DateTime.Today)).Returns(revenueObject); 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.Get(0, DateTime.Today)); }