public void LeaveNonExistingUser()
        {
            var command = new LeaveGroupCommand()
            {
                UserId  = 1,
                GroupId = 1
            };
            var handler = new LeaveGroupCommandHandler(Context);

            Assert.Throws <AggregateException>(() => handler.Handle(command, CancellationToken.None).Result);
        }
        public async void LeaveExistingGroupOk()
        {
            var user = new User()
            {
                Name     = "Sofia",
                LastName = "Cunha",
                Mail     = "*****@*****.**",
                Password = "******"
            };

            Context.Users.Add(user);
            var group = new Group()
            {
                Name        = "La pedrera",
                Admin       = user,
                Memberships = new List <Membership>()
            };

            Context.Groups.Add(group);
            var mem = new Membership()
            {
                User    = user,
                Group   = group,
                UserId  = user.Id,
                GroupId = group.Id
            };

            Context.Memberships.Add(mem);
            group.Memberships.Add(mem);
            var command = new LeaveGroupCommand()
            {
                UserId  = user.Id,
                GroupId = group.Id
            };
            var handler = new LeaveGroupCommandHandler(Context);

            await handler.Handle(command, CancellationToken.None);

            Assert.Empty(Memberships);
            Assert.NotEmpty(Groups);
        }