public void CollectionExtensions_Partition_Combinations() { var stuff = new [] { 1, 2, 3, 4 }.Select(x => x); // to convert to IEnumerable int[][] expecting = { new int[] {}, new[] {1}, new[] {1, 2}, new[] {2}, new[] {1, 2, 3}, new[] {2, 3}, new[] {1, 3}, new[] {3}, new[] {1, 2, 3, 4}, new[] {1, 2, 4}, new[] {1, 3, 4}, new[] {2, 3, 4}, new[] {3, 4}, new[] {2, 4}, new[] {1, 4}, new[] {4} }; var permutation = stuff.Combinations().Select(a => a.ToList()).ToList(); Assert.IsTrue( expecting.Select(i => permutation.Any(a => a.Count == i.Length && a.All(i.Contains))).All(b => b)); }
public void ParameterReaderIgnoreMissingMultipleNullableParameterTest() { IEdmModel model = TestModels.BuildModelWithFunctionImport(); IEdmOperationImport functionImport = model.FindEntityContainer("TestContainer").FindOperationImports("FunctionImport_MultipleNullableParameters").Single(); var parameterValues = new[] { "\"p1\" : \"AAEC\"", "\"p2\" : true", "\"p3\" : 1", "\"p5\" : \"2012-05-25T09:00:42.5018138-07:00\"", "\"p6\" : 79228162514264337593543950335", "\"p7\" : \"INF\"", "\"p8\" : \"446806b7-7d7f-4e60-9e2b-bc28d9671a4f\"", "\"p9\" : \"32767\"", "\"p10\" : 2147483647", "\"p11\" : 0", "\"p12\" : \"1\"", "\"p13\" : \"0.01\"", "\"p14\" : { type: \"Point\", coordinates: [ -122.107711791992, 47.6472206115723 ], crs: { type: \"name\", properties: { name: \"EPSG:4326\" } } }", "\"p15\" : \"foo\"", "\"p16\" : { @odata.type: \"#TestModel.ComplexTypeWithNullableProperties\", IntegerProperty: 1 }", "\"p17\" : \"enumType1_value2\"", // supports reading enum values without validation }; var multipleParameterTestCases = parameterValues.Combinations(false, new[] { 1, 2, 16 }).ToArray(); this.CombinatorialEngineProvider.RunCombinations( multipleParameterTestCases, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(c => c.IsRequest == true), (testCase, testConfiguration) => { string payload = "{" + string.Join(",", testCase) + "}"; var reader = this.CreateParameterReaderForRequestOrResponse(model, functionImport, testConfiguration, payload); foreach (var parameter in testCase) { this.Assert.IsTrue(reader.Read(), "Read() should not fail for payload " + payload); this.Assert.AreEqual(ODataParameterReaderState.Value, reader.State, "State should be Value."); } this.Assert.IsFalse(reader.Read(), "Read() should fail after reading all parameters"); this.Assert.AreEqual(ODataParameterReaderState.Completed, reader.State, "State should be Complete."); }); }