public void DateRangeTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); testRecord.AddExpense(testExpense); DateTime[] testrange = { testdate, testdate2 }; Assert.NotEqual(testRecord.DateRange(), testrange); testRecord.AddExpense(testExpense2); Assert.Equal(testRecord.DateRange(), testrange); }
public void ReadFromFileTest() { var f = new FileReader(); var testRecord = new SSE662Project1.Objects.Record(recordname); var testRecord2 = new SSE662Project1.Objects.Record(recordname); testRecord.AddExpense(testExpense); testRecord.AddExpense(testExpense2); Assert.False(testRecord.Equals(testRecord2)); f.ReadFromFile(filename, testRecord2); output.WriteLine(testRecord.ToString()); output.WriteLine(testRecord2.ToString()); Assert.True(testRecord.Equals(testRecord2)); }
public void CategoryTotalsTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); Assert.NotEqual(testcategory.categoryID + " total: " + testprice.ToString(), testRecord.CategoryTotals()[1]); testRecord.AddExpense(testExpense); Assert.Equal(testcategory.categoryID + " total: " + testprice.ToString(), testRecord.CategoryTotals()[1]); }
public void RecordHashCodeTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); var testRecord2 = new SSE662Project1.Objects.Record(recordname2); Assert.NotEqual(testRecord.GetHashCode(), testRecord2.GetHashCode()); testRecord.AddExpense(testExpense); testRecord2.AddExpense(testExpense); Assert.NotEqual(testRecord.GetHashCode(), testRecord2.GetHashCode()); testRecord2.RecordName = recordname; Assert.Equal(testRecord.GetHashCode(), testRecord2.GetHashCode()); }
public void RecordToStringTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); var testRecord2 = new SSE662Project1.Objects.Record(recordname2); Assert.NotEqual(testRecord.ToString(), testRecord2.ToString()); testRecord.AddExpense(testExpense); testRecord2.AddExpense(testExpense); Assert.NotEqual(testRecord.ToString(), testRecord2.ToString()); testRecord2.RecordName = recordname; Assert.Equal(testRecord.ToString(), testRecord2.ToString()); }
public void RecordEqualsTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); var testRecord2 = new SSE662Project1.Objects.Record(recordname2); Assert.False(testRecord.Equals(testRecord2)); testRecord.AddExpense(testExpense); testRecord2.AddExpense(testExpense); Assert.False(testRecord.Equals(testRecord2)); testRecord2.RecordName = recordname; Assert.True(testRecord.Equals(testRecord2)); }
public void AddExpenseTest() { var testRecord = new SSE662Project1.Objects.Record(recordname); Assert.Equal(testRecord.RecordName, recordname); Assert.Empty(testRecord.Expenses); testRecord.AddExpense(testExpense); Assert.Equal(testRecord.RecordName, recordname); Assert.NotEmpty(testRecord.Expenses); Assert.Equal(testdate, testRecord.Expenses[0].ExpenseDate); Assert.Equal(testprice, testRecord.Expenses[0].ExpensePrice); Assert.Equal(vendorstring, testRecord.Expenses[0].ExpenseVendor); Assert.True(testcategory.Equals(testRecord.Expenses[0].ExpenseCategory)); }
public void ReadFromFile(string filename, Record record) { using (var reader = new StreamReader(filename)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); // Input file should be 'date, price, vendor' Expense expense = new Expense(values[0], values[1], values[2]); record.AddExpense(expense); } } }