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 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(); }