public void GetReturnsEventItemsFromStore()
        {
            var mockLogger = new Mock <ILogger <ScheduleController> >();
            var mockStore  = new Mock <IDataStore>();

            mockStore.Setup(x => x.GetSchedule()).Returns(fakeScheduleData);

            var service = new ScheduleController(mockLogger.Object, mockStore.Object);

            Assert.True(service.Get().Count() == 3);
            Assert.Equal(service.Get(), fakeScheduleData);
        }
        public void GetReturnsEmptyScheduleItemsArrayWhenStoryIsEmpty()
        {
            var mockLogger = new Mock <ILogger <ScheduleController> >();
            var mockStore  = new Mock <IDataStore>();

            mockStore.Setup(x => x.GetSchedule()).Returns(fakeEmptyScheduleData);

            var service = new ScheduleController(mockLogger.Object, mockStore.Object);

            Assert.Empty(service.Get());
        }
예제 #3
0
        public void GetScheduleById_WhereScheduleDoesntExist_ReturnsNotFound([Values(7, 8, 9)] int idOfScheduleToGet)
        {
            //arrange
            _mockScheduleService = Mock.Create <IScheduleService>();
            Mock.Arrange(() => _mockScheduleService.Get(Arg.IsAny <int>()))
            .DoInstead(() => _scheduleList.FirstOrDefault(x => x.ScheduleId == idOfScheduleToGet))
            .OccursOnce();

            var scheduleController = new ScheduleController(_mockScheduleService);

            //act
            var actual = scheduleController.Get(idOfScheduleToGet) as NotFoundResult;

            //assert
            Mock.Assert(_mockScheduleService);
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.TypeOf(typeof(NotFoundResult)));
        }
예제 #4
0
        public void GetScheduleById_WhereScheduleExists_ReturnsSchedule([Values(1, 2, 3)] int idOfScheduleToGet)
        {
            //Arrange
            Mock.Arrange(() => _mockScheduleService.Get(idOfScheduleToGet))
            .Returns(_scheduleList.FirstOrDefault(s => s.ScheduleId == idOfScheduleToGet))
            .OccursOnce();

            var expected = _scheduleList.FirstOrDefault(s => s.ScheduleId == idOfScheduleToGet);

            var scheduleController = new ScheduleController(_mockScheduleService);

            //Act
            var actual        = scheduleController.Get(idOfScheduleToGet) as OkNegotiatedContentResult <ScheduleDto>;
            var actualContent = actual.Content;


            //Assert
            Mock.Assert(_mockScheduleService);
            Assert.That(actualContent, Is.EqualTo(expected));
        }