public void GetHoldingsBothDates() { var mockRepository = new MockRepository(MockBehavior.Strict); var response = new List <Holding>(); var service = mockRepository.Create <IPortfolioHoldingService>(); service.Setup(x => x.GetHoldings(new DateRange(new Date(2000, 06, 01), new Date(2000, 12, 31)))).Returns(ServiceResult <List <Holding> > .Ok(response)).Verifiable(); var controller = new HoldingController(); var result = controller.Get(service.Object, null, new DateTime(2000, 06, 01), new DateTime(2000, 12, 31)); result.Result.Should().BeOkObjectResult().Value.Should().Be(response); mockRepository.VerifyAll(); }
public void GetHoldingNotFound() { var mockRepository = new MockRepository(MockBehavior.Strict); var stockId = Guid.NewGuid(); var service = mockRepository.Create <IPortfolioHoldingService>(); service.Setup(x => x.GetHolding(stockId, new Date(2000, 01, 01))).Returns(ServiceResult <Holding> .NotFound()).Verifiable(); var controller = new HoldingController(); var result = controller.Get(service.Object, stockId, new DateTime(2000, 01, 01)); result.Result.Should().BeNotFoundResult(); mockRepository.VerifyAll(); }
public void GetHoldingNoDate() { var mockRepository = new MockRepository(MockBehavior.Strict); var stockId = Guid.NewGuid(); var response = new Holding(); var service = mockRepository.Create <IPortfolioHoldingService>(); service.Setup(x => x.GetHolding(stockId, Date.Today)).Returns(ServiceResult <Holding> .Ok(response)).Verifiable(); var controller = new HoldingController(); var result = controller.Get(service.Object, stockId, null); result.Result.Should().BeOkObjectResult().Value.Should().Be(response); mockRepository.VerifyAll(); }