public async Task <bool> Post()
        {
            Users user = new Users()
            {
                Name = "张三",
                Sex  = Guid.NewGuid().ToString()
            };

            return(await _repositoryUser.AddAsync(user));
        }
예제 #2
0
        public async Task TestRemovePictureIdFromUserObityarysAsyncMethod()
        {
            var optionsBuilder   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("testDb4");
            var virtualDbContext = new ApplicationDbContext(optionsBuilder.Options);

            var obituaryRepository = new EFRepository <Obituary>(virtualDbContext);
            var pictureRepository  = new EFRepository <Picture>(virtualDbContext);

            var userPictureService = new UserPictureService(pictureRepository, obituaryRepository);

            var obituary = new Obituary
            {
                Id               = "ObituaryId1",
                UserId           = "UserId1",
                FrameId          = "frame1Id",
                TextTemplateId   = "ttId1",
                CustomTextId     = " CustomTextId1",
                CrossId          = "1",
                PictureId        = "PictureId1",
                AfterCrossTextId = "AfterCrossTextId1",
                CrossTextId      = "CrossTextId1",
                FromId           = "FromId1",
                FullNameId       = "FullNameId1",
                PanahidaId       = "PanahidaId1",
                YearId           = "YearId1",
            };

            await obituaryRepository.AddAsync(obituary);

            await obituaryRepository.SaveChangesAsync();

            await userPictureService
            .RemovePictureIdFromUserObityarysAsync("PictureId1");

            var dbObituary = obituaryRepository.All().FirstOrDefault();

            Assert.Null(dbObituary.PictureId);
        }