Exemple #1
0
        public async void SendNotificationShouldSaveNotificationAccordingly()
        {
            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));

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

            var dogsitter = new Dogsitter();
            var owner     = new Owner();

            await dogsitterRepository.AddAsync(dogsitter);

            await dogsitterRepository.SaveChangesAsync();

            await ownersService.SendNotification(dogsitter.Id, owner, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow);

            Assert.Equal(1, dogsitter.Notifications.Count);
        }
Exemple #2
0
        public async void SendNotificationShouldHaveCorrectOwnerAndDogsitter()
        {
            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));

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

            var dogsitter = new Dogsitter();
            var owner     = new Owner();

            await dogsitterRepository.AddAsync(dogsitter);

            await dogsitterRepository.SaveChangesAsync();

            await ownersService.SendNotification(dogsitter.Id, owner, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow);

            var trueOwnerDogsitter = dogsitter.Notifications.FirstOrDefault().OwnerId == owner.Id;

            Assert.True(trueOwnerDogsitter);
        }