Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void GetContributionChannelListAdvancedSearch_Success_Test()
        {
            // Arrange
            string name        = null;
            string description = null;
            bool?  active      = null;

            //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.GetContributionChannelListAdvancedSearch(
                           Moq.It.IsAny <string>()   // name
                           , Moq.It.IsAny <string>() // description
                           , Moq.It.IsAny <bool?>()  // active
                           )).Returns(list);

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            var resultList = contributionChannelService.GetContributionChannelListAdvancedSearch(
                name
                , description
                , active
                );

            ContributionChannelDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionChannelId);
        }
Esempio n. 4
0
        public void DeleteContributionChannelById_Success_Test()
        {
            // Arrange
            int id = 1;

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

            mock.Setup(s => s.DeleteContributionChannel(Moq.It.IsAny <int>())).Verifiable();

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            contributionChannelService.DeleteContributionChannel(id);

            // Assert
            Assert.IsTrue(true);
        }
Esempio n. 5
0
        public void UpdateContributionChannel_Success_Test()
        {
            // Arrange
            ContributionChannelDTO dto = SampleContributionChannelDTO(1);

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

            mock.Setup(s => s.UpdateContributionChannel(Moq.It.IsAny <R_ContributionChannel>())).Verifiable();

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            contributionChannelService.UpdateContributionChannel(dto);

            // Assert
            Assert.IsNotNull(dto);
        }
Esempio n. 6
0
        public void AddContributionChannel_Success_Test()
        {
            // Arrange
            ContributionChannelDTO dto = SampleContributionChannelDTO(1);

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

            mock.Setup(s => s.AddContributionChannel(Moq.It.IsAny <R_ContributionChannel>())).Returns(1);

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            int id = contributionChannelService.AddContributionChannel(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.ContributionChannelId);
        }
Esempio n. 7
0
        public void GetContributionChannel_Success_Test()
        {
            // Arrange
            int id = 1;
            R_ContributionChannel contributionChannel = SampleContributionChannel(id);

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

            mock.Setup(s => s.GetContributionChannel(Moq.It.IsAny <int>())).Returns(contributionChannel);

            // service
            ContributionChannelService contributionChannelService = new ContributionChannelService();

            ContributionChannelService.Repository = mock.Object;

            // Act
            ContributionChannelDTO result = contributionChannelService.GetContributionChannel(id);

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