Esempio n. 1
0
        public void TimelineService_Get_Test()
        {
            // Arrange
            Mock <ITimelineDao> mock = new Mock <ITimelineDao>(MockBehavior.Strict);

            mock.Setup(setup => setup.Find(It.IsAny <long>())).Returns(new Timeline()
            {
                Id = 1,
                RootContentItemId = 123,
                Title             = "1ste wereld oorlog",
                BeginDate         = 1914M,
                EndDate           = 1918M
            });
            Mock <IContentItemDao> contentItemMock = new Mock <IContentItemDao>(MockBehavior.Strict);

            contentItemMock.Setup(setup => setup.Find(It.IsAny <long>(), It.IsAny <int>())).Returns(new ContentItem()
            {
                Children = new ContentItem[2]
            });
            TimelineService target = new TimelineService(mock.Object, contentItemMock.Object);

            // Act
            Timeline result = target.Get(1);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual((long)1, result.Id);
            Assert.AreEqual("1ste wereld oorlog", result.Title);
            Assert.AreEqual(1914M, result.BeginDate);
            Assert.AreEqual(1918M, result.EndDate);
            Assert.IsNotNull(result.RootContentItem);
            Assert.AreEqual(2, result.RootContentItem.Children.Count());
            mock.Verify(verify => verify.Find(It.IsAny <long>()), Times.Once);
            contentItemMock.Verify(verify => verify.Find(result.RootContentItemId, It.IsAny <int>()), Times.Once);
        }
Esempio n. 2
0
        public void TimelineService_Get_Exception_Test()
        {
            // Arrange
            Mock <ITimelineDao>    mock            = new Mock <ITimelineDao>(MockBehavior.Strict);
            Mock <IContentItemDao> contentItemMock = new Mock <IContentItemDao>(MockBehavior.Strict);

            mock.Setup(setup => setup.Find(It.IsAny <long>())).Throws(new Exception());
            TimelineService target = new TimelineService(mock.Object, contentItemMock.Object);

            // Act
            target.Get(1);
        }