public void CreateSNSTest() { /* arrange : 저장할 SNS공유 정보 */ var user = CreateUser()[0]; mockUserRepository.Setup(x => x.SingleOrDefault(It.IsAny <Expression <Func <MavelFrozenUser, bool> > >())).Returns(user); var sharing = new MavelFrozenSNS { 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 <MavelFrozenSNS>())).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 <MavelFrozenUser, bool> > >()), Times.Once); mockSNSRepository.Verify(x => x.Add(It.IsAny <MavelFrozenSNS>()), Times.Once); mockSNSRepository.Verify(x => x.Save(), Times.Once); }
public MavelFrozenSNS CreateMarvelFrozenSNS(MarvelFrozenSnsModel model) { if (common.Now < new DateTime(2017, 4, 24, 9, 0, 0)) { throw new EventServiceException("400", "4월 24일 월요일 오전 9시부터 참여가능합니다 :)", null); } if (common.Now >= new DateTime(2017, 5, 20)) { throw new EventServiceException("400", "5월 19일 이벤트가 종료되었습니다.", null); } var mapper = mapperConfig.CreateMapper(); var entry = mapper.Map <MavelFrozenSNS>(model); entry.CreateDate = common.Now; var result = service.CreateSNSShare(entry); return(result); }