Beispiel #1
0
        public async void DogsitterDetailsByIdTemplateShouldReturnProperType()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var userRepository      = new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options));
            var dogsitterRepository = new EfDeletableEntityRepository <Dogsitter>(new ApplicationDbContext(options.Options));
            var ownerRepository     = new EfDeletableEntityRepository <Owner>(new ApplicationDbContext(options.Options));

            AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly);

            var ownersService = new OwnersService(userRepository, ownerRepository, dogsitterRepository);

            var dogsitter = new Dogsitter();

            await dogsitterRepository.AddAsync(dogsitter);

            await dogsitterRepository.SaveChangesAsync();

            var dogsitterDb = ownersService.DogsitterDetailsById <DogsitterInfoViewModel>(dogsitter.Id);

            Assert.IsType <DogsitterInfoViewModel>(dogsitterDb);
        }