public void Home_Developer_Documentation_GetEmissionFactors() { var client = new Client(new Uri(AmeeUrl), AmeeUserName, AmeePassword); // Performing Drilldowns const string path = "transport/defra/fuel"; // get choices for transport/defra/fuel DrillDownResponse r = client.GetDrillDown(path); // drill down to petrol var choice = r.Choices.Choices.FirstOrDefault(c => c.Name == "petrol"); Assert.IsNotNull(choice); var selectionName = r.Choices.Name; var selection = new ValueItem(selectionName, choice.Name); // get the uid for petrol r = client.GetDrillDown(path, selection); // this is the end of this drilldown hierarchy. if more levels existed we would repeat previous step // but in this case, the choices will be 'uid' with a single value that we use to get a data item Assert.AreEqual("uid", r.Choices.Name); Assert.AreEqual(1, r.Choices.Choices.Count); choice = r.Choices.Choices[0]; // Fetching Data Items // use the uid to fetch the data item // (appears that the choice 'name' is the value to use and, when present, 'value' echoes 'name') DataItemResponse item = client.GetDataItem(path, choice.Name); // go ahead and hover item and explore. have yet to determine different response formats for different paths but DataItemResponse // seems to cover this path // Do Calculation // var profile = client.CreateProfile(); // // var calc = client.Calculate(profile.Profile.Uid, path, new ValueItem("dataItemUid", item.DataItem.Uid), new ValueItem("volume", "500"), new ValueItem("representation", "full")); // // Assert.AreEqual("1155.8500000000001", calc.totalAmount.Value); // // var defaultAmount = calc.profileItems[0].Amounts.Amount.FirstOrDefault(a => a.Default); // Assert.IsNotNull(defaultAmount); // // rounding error between total and defaultAmount // Expected string length 18 but was 7. Strings differ at index 7. // Expected: "1155.8500000000001" // But was: "1155.85" // Assert.AreEqual(calc.totalAmount.Value, defaultAmount.Value); // // var relatedAmount = calc.profileItems[0].Amounts.Amount.FirstOrDefault(a => a.Type == "lifeCycleCO2e"); // Assert.IsNotNull(relatedAmount); // Assert.AreEqual("1361.35", relatedAmount.Value); }