示例#1
0
 public async Task <IEnumerable <GroupModel> > Handle(GetGroupsQuery request, CancellationToken cancellationToken)
 {
     return(await _context.Groups
            .Include(group => group.Admin)
            .Include(group => group.Purchases)
            .Include(group => group.Memberships)
            .Select(group => MapToModel(group))
            .ToListAsync(cancellationToken: cancellationToken));
 }
示例#2
0
        public async void GetGroupWithPurchase()
        {
            var query = new GetGroupsQuery();

            HttpResponseMessage response = await _client.GetAsync(GroupUrl + "/1");

            response.EnsureSuccessStatusCode();
            GroupModel group = await response.DeserializeObject <GroupModel>();

            Assert.True(group.Purchases.Count(p => p == 1) == 1);
        }
示例#3
0
        public async void GetUserPurchase()
        {
            var query = new GetGroupsQuery();

            HttpResponseMessage response = await _client.GetAsync(UsersUrl + "/1/purchases");

            response.EnsureSuccessStatusCode();
            PurchaseModel purchase = (await response.DeserializeCollection <PurchaseModel>()).SingleOrDefault();

            Assert.Equal(1, purchase.Id);
            Assert.True(purchase.Participants.All(p => p.Id == 2 || p.Id == 1));
            Assert.Equal(1, purchase.Purchaser);
            Assert.Equal(15U, purchase.Cost);
        }
示例#4
0
        public async void GetGroups()
        {
            var query = new GetGroupsQuery();

            HttpResponseMessage response = await _client.GetAsync(GroupUrl);

            response.EnsureSuccessStatusCode();
            IEnumerable <GroupModel> groups = await response.DeserializeCollection <GroupModel>();

            Assert.Single(groups);
            GroupModel group = groups.Single();

            Assert.Equal(1, group.Id);
            Assert.Equal(1, group.Admin);
            Assert.Equal("Red Wedding", group.Name);
            Assert.True(group.Memberships.All(m => m.Id == 2 || m.Id == 3 || m.Id == 1));
        }