Example #1
0
        public void TimelineService_GetAllPublicTimelinesWithoutContentItems_Exception_Test()
        {
            // Arrange
            Mock<ITimelineDao> mock = new Mock<ITimelineDao>(MockBehavior.Strict);
            Mock<IContentItemDao> contentItemMock = new Mock<IContentItemDao>(MockBehavior.Strict);
            mock.Setup(setup => setup.FindAllPublicTimelines()).Throws(new Exception());
            TimelineService target = new TimelineService(mock.Object, contentItemMock.Object);

            // Act
            target.GetAllPublicTimelinesWithoutContentItems();
        }
Example #2
0
        public void TimelineService_GetAllPublicTimelinesWithoutContentItems_Test()
        {
            // Arrange
            Mock<ITimelineDao> mock = new Mock<ITimelineDao>(MockBehavior.Strict);
            mock.Setup(setup => setup.FindAllPublicTimelines()).Returns(new List<Timeline>()
            {
                new Timeline()
                {
                    Id = 1,
                    Title = "1ste wereld oorlog",
                    BeginDate = 1914M,
                    EndDate = 1918M,
                    IsPublic = true
                },
                new Timeline()
            });
            TimelineService target = new TimelineService(mock.Object, null);

            // Act
            IEnumerable<Timeline> result = target.GetAllPublicTimelinesWithoutContentItems();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Timeline firstResult = result.First();
            Assert.AreEqual((long)1, firstResult.Id);
            Assert.AreEqual("1ste wereld oorlog", firstResult.Title);
            Assert.AreEqual(1914M, firstResult.BeginDate);
            Assert.AreEqual(1918M, firstResult.EndDate);
            Assert.AreEqual(null, firstResult.RootContentItem);
            mock.Verify(verify => verify.FindAllPublicTimelines(), Times.Once);
        }