Ejemplo n.º 1
0
        public async void GetOwnerByIdShouldThrowNullReferenceExceptionWhenWrongId()
        {
            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 user = new ApplicationUser();

            await ownersService.CreateOwnerAsync(user, Info, Info, Info, Info, Gender.Male, Info, Info, user.Id, Info);

            var owner = ownersService.GetOwnerById("");

            Assert.Throws <NullReferenceException>(() => owner.Id);
        }
Ejemplo n.º 2
0
        public async void UpdateCurrentLoggedInUserInfoAsyncShouldUpdateValuesAccordingly()
        {
            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 user = new ApplicationUser();

            await ownersService.CreateOwnerAsync(user, Info, Info, Info, Info, Gender.Male, Info, Info, user.Id, Info);

            await ownersService.UpdateCurrentLoggedInUserInfoAsync(user.Id, "NewName", Info, Info, Info, Info, Info);

            var owner = ownersService.GetOwnerById(user.Id);

            Assert.Equal("NewName", owner.FirstName);
        }
Ejemplo n.º 3
0
        public async void GetOwnerByIdShouldReturnCorrectOwner()
        {
            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 user  = new ApplicationUser();
            var user2 = new ApplicationUser();

            await ownersService.CreateOwnerAsync(user, Info, Info, Info, Info, Gender.Male, Info, Info, user.Id, Info);

            await ownersService.CreateOwnerAsync(user2, Info, Info, Info, Info, Gender.Male, Info, Info, user2.Id, Info);

            var owner = ownersService.GetOwnerById(user.Id);

            Assert.Equal(user.Id, owner.UserId);
        }