public async Task ShouldRequestListFromTheApiWithAllParameters()
        {
            var client = Mock.Of <ApiClient>();

            IList <TeachingGroup> teachingGroups = new List <TeachingGroup>()
            {
                new TeachingGroup(), new TeachingGroup()
            };

            var yearCode    = "a";
            var subjectCode = "123";

            Mock.Get(client).Setup(c => c.GetList <TeachingGroup>(
                                       "teaching_groups",
                                       It.Is <ExpandoObject>(x =>
                                                             x.V <string>("year_code") == "a" &&
                                                             x.V <string>("subject_code") == subjectCode))).Returns(Task.FromResult(teachingGroups)).Verifiable();

            var resource = new TeachingGroupsResource(client);
            var results  = await resource.List(subjectCode : subjectCode, yearCode : yearCode);

            Assert.That(results.Count, Is.EqualTo(teachingGroups.Count));

            Mock.Get(client).VerifyAll();
        }
        public async Task ShouldRequestAnItemFromTheApi()
        {
            var client = Mock.Of <ApiClient>();

            var item = new TeachingGroup();

            int itemId = 1;

            Mock.Get(client).Setup(c => c.GetObject <TeachingGroup>(
                                       $"teaching_groups/{itemId}", It.IsAny <ExpandoObject>())).Returns(Task.FromResult(item)).Verifiable();

            var teachingGroupsResource = new TeachingGroupsResource(client);
            var result = await teachingGroupsResource.Find(itemId);

            Mock.Get(client).VerifyAll();
        }
        public async Task ShouldRequestAllFromTheApi()
        {
            var client = Mock.Of <ApiClient>();

            IList <TeachingGroup> students = new List <TeachingGroup>()
            {
                new TeachingGroup(), new TeachingGroup()
            };

            Mock.Get(client).Setup(c => c.GetList <TeachingGroup>("teaching_groups", It.IsAny <ExpandoObject>())).Returns(Task.FromResult(students));

            var resource = new TeachingGroupsResource(client);

            await resource.All();

            Mock.Get(client).VerifyAll();
        }
        public async Task ShouldRequestListFromTheApiWithOnlySomeParameters()
        {
            var client = Mock.Of <ApiClient>();

            IList <TeachingGroup> students = new List <TeachingGroup>()
            {
                new TeachingGroup(), new TeachingGroup()
            };

            Mock.Get(client).Setup(c => c.GetList <TeachingGroup>(
                                       "teaching_groups",
                                       It.Is <ExpandoObject>(x => x.V("year_code") == null))).Returns(Task.FromResult(students)).Verifiable();

            var teachingGroupsResource = new TeachingGroupsResource(client);
            var results = await teachingGroupsResource.List();

            Assert.That(results.Count, Is.EqualTo(students.Count));

            Mock.Get(client).VerifyAll();
        }
        public async Task TeachingGroupFetchesStudents()
        {
            IList <Student> students = new List <Student>()
            {
                new Student(), new Student()
            };

            var client = Mock.Of <ApiClient>();

            var resource = new TeachingGroupsResource(client);

            var teachingGroup = new TeachingGroup();

            teachingGroup.Resource = resource;

            var resourceAddress = $"{TeachingGroupsResource.ResourceName}/{teachingGroup.Id}/students";

            Mock.Get(client).Setup(c => c.GetList <Student>(resourceAddress, It.IsAny <ExpandoObject>())).Returns(Task.FromResult(students));

            var results = await teachingGroup.Students();

            Assert.That(results.First().FirstName, Is.EqualTo(students.First().FirstName));
        }