Ejemplo n.º 1
0
        public async Task GetAddressByUserIdShouldGetAddress()
        {
            var dbContext   = ApplicationDbContextInMemoryFactory.InitializeContext();
            var repository  = new EfDeletableEntityRepository <UserAddress>(dbContext);
            var service     = new AddressesService(repository);
            var userManager = MockUserManager.GetUserManager();

            var user = new ApplicationUser
            {
                Email    = "*****@*****.**",
                UserName = "******",
            };
            await userManager.CreateAsync(user);

            var userAddress = new UserAddress()
            {
                UserId = user.Id,
            };
            await service.CreateAsync(userAddress);

            var userAddressInvalid = new UserAddress()
            {
                UserId = "none",
            };
            await service.CreateAsync(userAddressInvalid);

            var foundAddress =
                await service.GetBaseByUserId(user.Id);

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