Beispiel #1
0
        public void CreateSNSTest()
        {
            /* arrange : 저장할 SNS공유 정보 */
            var user = CreateUser()[0];

            mockUserRepository.Setup(x => x.SingleOrDefault(It.IsAny <Expression <Func <FindingDory2017User, bool> > >())).Returns(user);
            var sharing = new FindingDory2017SNS
            {
                Id         = 1,
                UserId     = user.Id,
                SnsType    = Domain.Abstract.SnsType.Facebook,
                SnsId      = "1234567",
                SnsName    = "테스트",
                Post       = "http://facebook.com",
                CreateDate = new DateTime(2017, 2, 10)
            };

            mockSNSRepository.Setup(x => x.Add(It.IsAny <FindingDory2017SNS>())).Returns(sharing);
            mockSNSRepository.Setup(x => x.Save());

            /* action : SNS공유 정보 저장 서비스 실행 */
            var result = service.CreateSNSShare(sharing);

            /* assert : 검증 */
            Assert.NotNull(result);
            Assert.Equal(user.Id, result.UserId);
            mockUserRepository.Verify(x => x.SingleOrDefault(It.IsAny <Expression <Func <FindingDory2017User, bool> > >()), Times.Once);
            mockSNSRepository.Verify(x => x.Add(It.IsAny <FindingDory2017SNS>()), Times.Once);
            mockSNSRepository.Verify(x => x.Save(), Times.Once);
        }
Beispiel #2
0
        /// <summary>
        /// 공유 데이터 저장
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        public FindingDory2017SNS CreateSNSShare(FindingDory2017SNS entry)
        {
            var user = userRepository.SingleOrDefault(x => x.Id == entry.UserId);

            if (user == null)
            {
                throw new EventServiceException("500", "참여자 정보가 잘못되었습니다.", entry);
            }

            var result = snsRepository.Add(entry);

            snsRepository.Save();
            return(result);
        }