public async Task ShouldRequestListFromTheApiWithOnlySomeParameters() { var client = Mock.Of <ApiClient>(); IList <Student> students = new List <Student>() { new Student(), new Student() }; bool demographics = true; Mock.Get(client).Setup( c => c.GetList <Student>( "students", It.Is <ExpandoObject>(x => x.V <bool>("demographics") == demographics && x.V("year_code") == null))).Returns(Task.FromResult(students)).Verifiable(); var studentResources = new StudentsResource(client); var results = await studentResources.List(demographics : demographics); Assert.That(results.Count, Is.EqualTo(students.Count)); Mock.Get(client).VerifyAll(); }
public async Task ShouldRequestListFromTheApiWithAllParameters() { var client = Mock.Of <ApiClient>(); IList <Student> students = new List <Student>() { new Student(), new Student() }; var yearCode = "a"; var academicYearId = "123"; bool demographics = true; Mock.Get(client).Setup(c => c.GetList <Student>( "students", It.Is <ExpandoObject>(x => x.V <string>("year_code") == "a" && x.V <string>("academic_year_id") == academicYearId && x.V <bool>("demographics") == demographics))).Returns(Task.FromResult(students)).Verifiable(); var studentResources = new StudentsResource(client); var results = await studentResources.List(academicYearId : academicYearId, yearCode : yearCode, demographics : demographics); Assert.That(results.Count, Is.EqualTo(students.Count)); Mock.Get(client).VerifyAll(); }