public void FromExpenseTest() { Expense e = new Expense( 50f, DateTime.Today, "Walmart", new Card(), new HashSet <string> { "food", "hygene" }, "Bought groceries and handsoap"); ExpenseFilter f = new ExpenseFilter( name: "TestFilter", 50f, DateTime.Today, new HashSet <string> { "Walmart" }, new HashSet <string> { "food", "hygene" }); Assert.IsTrue(f.FunctionalEquals(ExpenseFilter.FromExpense("OtherFilter", e))); }
public void UnionTest() { // case 1: Filters have no intersection. ExpenseFilter f1 = new ExpenseFilter( name: "TestFilter", 1000f, DateTime.Today.AddYears(5), new HashSet <string> { "Walmart" }, new HashSet <string> { "Groceries", "Food" }, new HashSet <string> { "ChexMix" }, new Card()); ExpenseFilter f2 = new ExpenseFilter( name: "TestFilter", -1000f, DateTime.Today.AddYears(-5), new HashSet <string> { "ToysRUs" }, new HashSet <string> { "Games" }, new HashSet <string> { "Mario" }, new Cash()); ExpenseFilter fSolution = new ExpenseFilter( name: "TestFilter", 1000f, -1000f, DateTime.Today.AddYears(5), DateTime.Today.AddYears(-5), new HashSet <string> { "Walmart", "ToysRUs" }, new HashSet <string> { "Groceries", "Games", "Food" }, new HashSet <string> { "ChexMix", "Mario" }); ExpenseFilter fUnion = ExpenseFilter.Union(f1, f2); Assert.IsTrue(fSolution.FunctionalEquals(fUnion)); // case 2: Filters have a intersection. f1 = new ExpenseFilter( name: "TestFilter", 1000f, -1000f, DateTime.Today.AddYears(5), DateTime.Today.AddYears(-5), new HashSet <string> { "Walmart" }, new HashSet <string> { "Groceries", "Food" }, new HashSet <string> { "ChexMix" }, new Card()); f2 = new ExpenseFilter( name: "TestFilter", 1500f, -500f, DateTime.Today.AddYears(7), DateTime.Today.AddYears(-2), new HashSet <string> { "ToysRUs" }, new HashSet <string> { "Games" }, new HashSet <string> { "Mario" }, new Card()); fSolution = new ExpenseFilter( name: "TestFilter", 1500f, -1000f, DateTime.Today.AddYears(7), DateTime.Today.AddYears(-5), new HashSet <string> { "Walmart", "ToysRUs" }, new HashSet <string> { "Groceries", "Games", "Food" }, new HashSet <string> { "ChexMix", "Mario" }, new Card()); fUnion = ExpenseFilter.Union(f1, f2); Assert.IsTrue(fSolution.FunctionalEquals(fUnion)); }