예제 #1
0
        public void GetContributionTypesPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

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

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

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

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

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            var resultList             = contributionTypeService.GetContributionTypes(searchTerm, pageIndex, pageSize);
            ContributionTypeDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionTypeId);
            Assert.AreEqual(10, resultList.Count);
        }
예제 #2
0
        public void GetContributionTypes_Success_Test()
        {
            // Arrange
            R_ContributionType contributionType = SampleContributionType(1);

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

            list.Add(contributionType);

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

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

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            var resultList             = contributionTypeService.GetContributionTypes();
            ContributionTypeDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionTypeId);
        }
예제 #3
0
        public void GetContributionTypeListAdvancedSearch_Success_Test()
        {
            // Arrange
            string name        = null;
            string description = null;
            bool?  active      = null;

            //int pageIndex = 0;
            int pageSize = 10;

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

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

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

            mock.Setup(s => s.GetContributionTypeListAdvancedSearch(
                           Moq.It.IsAny <string>()   // name
                           , Moq.It.IsAny <string>() // description
                           , Moq.It.IsAny <bool?>()  // active
                           )).Returns(list);

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            var resultList = contributionTypeService.GetContributionTypeListAdvancedSearch(
                name
                , description
                , active
                );

            ContributionTypeDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.ContributionTypeId);
        }
예제 #4
0
        public void DeleteContributionTypeById_Success_Test()
        {
            // Arrange
            int id = 1;

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

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

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            contributionTypeService.DeleteContributionType(id);

            // Assert
            Assert.IsTrue(true);
        }
예제 #5
0
        public void UpdateContributionType_Success_Test()
        {
            // Arrange
            ContributionTypeDTO dto = SampleContributionTypeDTO(1);

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

            mock.Setup(s => s.UpdateContributionType(Moq.It.IsAny <R_ContributionType>())).Verifiable();

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            contributionTypeService.UpdateContributionType(dto);

            // Assert
            Assert.IsNotNull(dto);
        }
예제 #6
0
        public void AddContributionType_Success_Test()
        {
            // Arrange
            ContributionTypeDTO dto = SampleContributionTypeDTO(1);

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

            mock.Setup(s => s.AddContributionType(Moq.It.IsAny <R_ContributionType>())).Returns(1);

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            int id = contributionTypeService.AddContributionType(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.ContributionTypeId);
        }
예제 #7
0
        public void GetContributionType_Success_Test()
        {
            // Arrange
            int id = 1;
            R_ContributionType contributionType = SampleContributionType(id);

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

            mock.Setup(s => s.GetContributionType(Moq.It.IsAny <int>())).Returns(contributionType);

            // service
            ContributionTypeService contributionTypeService = new ContributionTypeService();

            ContributionTypeService.Repository = mock.Object;

            // Act
            ContributionTypeDTO result = contributionTypeService.GetContributionType(id);

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