public async Task ShouldBeEmptyForUserWithNoDevices()
        {
            User user = new User { Id = 3 };
            IEnumerable<Device> actual = await Repository.GetDevicesAsync(user);

            actual.ShouldBeEmpty();
        }
        public async Task ShouldReturnNoDevicesForNonExistinUser()
        {
            User user = new User { Id = 0 };
            IEnumerable<Device> actual = await Repository.GetDevicesAsync(user);

            actual.ShouldBeEmpty();
        }
        public async Task ShouldReturnAllStoredDevicesForUser()
        {
            User user = new User { Id = 1 };
            IEnumerable<Device> actual = await Repository.GetDevicesAsync(user);

            actual.Count().ShouldEqual(1);
        }
        public async Task CreateAsync(User user)
        {
            Context.Users.Add(user);

            await Context.SaveChangesAsync();
        }
        public async Task UpdateAsync(User user)
        {
            Context.Set<User>().AddOrUpdate(user);

            await Context.SaveChangesAsync();
        }
Esempio n. 6
0
 public IEnumerable<Device> GetDevices(User user)
 {
     return Context.Devices
                   .Where(device => device.UserId == user.Id)
                   .ToList();
 }
Esempio n. 7
0
 public async Task<IEnumerable<Device>> GetDevicesAsync(User user)
 {
     return await Context.Devices
                         .Where(device => device.UserId == user.Id)
                         .ToListAsync();
 }