示例#1
0
        public void NinjaBarbie2016UpdateUserTest()
        {
            /* arrange : 저장할 참여자 정보 */
            var user = new NinjaBarbie2016User {
                Id            = 1,
                Name          = "테스트",
                Mobile        = "01012345678",
                Age           = 28,
                Channel       = "web",
                ZipCode       = "12345",
                Address       = "서울시 강남구 역삼동 735-22",
                AddressDetail = "갈라빌딩 9층 개발팀",
                CreateDate    = new DateTime(2016, 11, 15),
                SurprizeType  = NinjaBarbieSurprizeType.NINJA
            };

            mockUserRepository.Setup(x => x.SingleOrDefault(It.IsAny <Expression <Func <NinjaBarbie2016User, bool> > >())).Returns(user);
            user.Top       = 1;
            user.Bottom    = 1;
            user.Accessory = 1;
            mockUserRepository.Setup(x => x.Update(It.IsAny <NinjaBarbie2016User>())).Returns(user);
            mockUserRepository.Setup(x => x.Save());

            /* action : 참여자 정보 저장 서비스 실행 */
            var result = service.UpdateUser(user);

            /* assert : 검증 */
            Assert.NotNull(result);
            Assert.Equal(user.Top, result.Top);
            mockUserRepository.Verify(x => x.SingleOrDefault(It.IsAny <Expression <Func <NinjaBarbie2016User, bool> > >()), Times.Once);
            mockUserRepository.Verify(x => x.Update(It.IsAny <NinjaBarbie2016User>()), Times.Once);
            mockUserRepository.Verify(x => x.Save(), Times.Once);
        }
示例#2
0
        public NinjaBarbie2016SharingViewModel SaveSurprize(NinjaBarbie2016SurprizeViewModel model)
        {
            byte[]       byteArray = Convert.FromBase64String(model.FacebookImage);
            MemoryStream stream    = new MemoryStream(byteArray);

            model.FacebookImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            byteArray            = Convert.FromBase64String(model.KakaotalkImage);
            stream               = new MemoryStream(byteArray);
            model.KakaotalkImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            byteArray             = Convert.FromBase64String(model.KakaostoryImage);
            stream                = new MemoryStream(byteArray);
            model.KakaostoryImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            var user = service.GetUsers().Where(x => x.Id == model.UserId).SingleOrDefault();

            if (user == null)
            {
            }
            var mapper = mapperConfig.CreateMapper();
            var entry  = mapper.Map <NinjaBarbie2016SurprizeViewModel, NinjaBarbie2016User>(model, user);
            var update = service.UpdateUser(entry);

            return(new NinjaBarbie2016SharingViewModel {
                UserId = update.Id,
                FacebookImage = update.FacebookImage,
                KakaotalkImage = update.KakaotalkImage,
                KakaostoryImage = update.KakaostoryImage
            });
        }