示例#1
0
        public async void TestCreatePetAsync()
        {
            // Arrange
            AppDbContext   appDbContext   = AppDbContextMock.GetAppDbContext();
            PetRepository  petRepository  = new PetRepository(appDbContext);
            UserRepository userRepository = new UserRepository(appDbContext);
            PetService     petService     = new PetService(petRepository, userRepository, new UnitOfWork(appDbContext));

            appDbContext.Users.Add(new User {
                Id = 215, Name = "Michael"
            });
            appDbContext.SaveChangesAsync().Wait();

            // Act
            var pet = await petService.CreateAsync(new Cat { Name = "Clause", UserId = 215 });

            // Assert
            Assert.NotNull(pet);
        }