Beispiel #1
0
        public void GetContributionChannelsPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_ContributionChannel> list = new List <R_ContributionChannel>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleContributionChannel(i));
            }

            // create mock for repository
            var mock = new Mock <IContributionChannelRepository>();

            mock.Setup(s => s.GetContributionChannels(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            var resultList = contributionChannelService.GetContributionChannels(searchTerm, pageIndex, pageSize);
            ContributionChannelDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionChannelId);
            Assert.AreEqual(10, resultList.Count);
        }
Beispiel #2
0
        public void GetContributionChannels_Success_Test()
        {
            // Arrange
            R_ContributionChannel contributionChannel = SampleContributionChannel(1);

            IList <R_ContributionChannel> list = new List <R_ContributionChannel>();

            list.Add(contributionChannel);

            // create mock for repository
            var mock = new Mock <IContributionChannelRepository>();

            mock.Setup(s => s.GetContributionChannels()).Returns(list);

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            var resultList = contributionChannelService.GetContributionChannels();
            ContributionChannelDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionChannelId);
        }