public void MakeClassrooms() { var classrooms = new List <Classroom>(); for (int i = 0; i < 2; i++) { var newClassroom = new Classroom(); newClassroom.BuildingId = "1234"; newClassroom.Id = i.ToString(); newClassroom.Name = "Name" + i; newClassroom.PiID = "PI" + i; classrooms.Add(newClassroom); } var result = _json.MakeClassrooms(classrooms); var expected = JObject.Parse(@"{ 'Classroom': { '1': { 'Id': '0', 'Name': 'Name0' }, '2': { 'Id': '1', 'Name': 'Name1' } } }"); Assert.Equal(expected.ToString(), result.ToString()); }