Example #1
0
        public void Update()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var tradingCalendar = new RestApi.TradingCalendars.TradingCalendar();

            var service = mockRepository.Create <ITradingCalendarService>();

            service.Setup(x => x.Update(tradingCalendar)).Returns(ServiceResult.Ok()).Verifiable();

            var controller = new TradingCalendarController(service.Object);
            var result     = controller.Update(2010, tradingCalendar);

            result.Should().BeOkResult();

            mockRepository.VerifyAll();
        }
Example #2
0
        public void UpdateValidationError()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var tradingCalendar = new RestApi.TradingCalendars.TradingCalendar();

            var service = mockRepository.Create <ITradingCalendarService>();

            service.Setup(x => x.Update(tradingCalendar)).Returns(ServiceResult.Error("Error message")).Verifiable();

            var controller = new TradingCalendarController(service.Object);
            var result     = controller.Update(2010, tradingCalendar);

            result.Should().BeBadRequestObjectResult().Error.Should().BeEquivalentTo(new [] { "Error message" });

            mockRepository.VerifyAll();
        }