/Rhino.Etl.Tests/Aggregation/AggregationFixture.cs

http://github.com/ayende/rhino-etl · C# · 60 lines · 54 code · 6 blank · 0 comment · 0 complexity · 4f42ee40d35c933cabe046aaf5703ef8 MD5 · raw file

  1. namespace Rhino.Etl.Tests.Aggregation
  2. {
  3. using System.Collections.Generic;
  4. using Core;
  5. using Xunit;
  6. public class AggregationFixture : BaseAggregationFixture
  7. {
  8. [Fact]
  9. public void AggregateRowCount()
  10. {
  11. using (RowCount rowCount = new RowCount())
  12. {
  13. IEnumerable<Row> result = rowCount.Execute(rows);
  14. List<Row> items = new List<Row>(result);
  15. Assert.Equal(1, items.Count);
  16. Assert.Equal(6, items[0]["count"]);
  17. }
  18. }
  19. [Fact]
  20. public void AggregateCostPerProduct()
  21. {
  22. using (CostPerProductAggregation aggregation = new CostPerProductAggregation())
  23. {
  24. IEnumerable<Row> result = aggregation.Execute(rows);
  25. List<Row> items = new List<Row>(result);
  26. Assert.Equal(3, items.Count);
  27. Assert.Equal("milk", items[0]["name"]);
  28. Assert.Equal("sugar", items[1]["name"]);
  29. Assert.Equal("coffee", items[2]["name"]);
  30. Assert.Equal(30, items[0]["cost"]);
  31. Assert.Equal(28, items[1]["cost"]);
  32. Assert.Equal(6, items[2]["cost"]);
  33. }
  34. }
  35. [Fact]
  36. public void SortedAggregateCostPerProduct()
  37. {
  38. using (SortedCostPerProductAggregation aggregation = new SortedCostPerProductAggregation())
  39. {
  40. IEnumerable<Row> result = aggregation.Execute(rows);
  41. List<Row> items = new List<Row>(result);
  42. Assert.Equal(4, items.Count);
  43. Assert.Equal("milk", items[0]["name"]);
  44. Assert.Equal("sugar", items[1]["name"]);
  45. Assert.Equal("coffee", items[2]["name"]);
  46. Assert.Equal("sugar", items[3]["name"]);
  47. Assert.Equal(30, items[0]["cost"]);
  48. Assert.Equal(25, items[1]["cost"]);
  49. Assert.Equal(6, items[2]["cost"]);
  50. Assert.Equal(3, items[3]["cost"]);
  51. }
  52. }
  53. }
  54. }