public void Consultant_CreateExpense_Returns_ActionResult() { //Arrange ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); //Act var result = controller.CreateExpense(); //Assert Assert.IsInstanceOfType(result,typeof(ActionResult),"The result was not a type of ActionResult"); }
public void Consultant_CreateExpense_Returns_View_CreateExpense() { //Arrange const string expectedViewName = "CreateExpense"; ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); //Act var result = controller.CreateExpense() as ViewResult; //Assert Assert.AreEqual(expectedViewName, result.ViewName, "View name should have been {0}", expectedViewName); }
public void Consultant_CreateExpense_CheckInitialExpenseReportIsInitialized() { //Arrange ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); ExpenseReport expenseReport = new ExpenseReport(); expenseReport.CreateDate = DateTime.Now; expenseReport.CreatedBy = mockEmployee; expenseReport.Department = mockEmployee.Department; Assert.AreEqual(expenseReport.CreatedBy, mockEmployee, "The createby employee is not equal"); Assert.AreEqual(String.Format("{0:dd/mm/yyyy}",expenseReport.CreateDate),String.Format("{0:dd/mm/yyyy}",DateTime.Now), "Create date is not same"); Assert.AreEqual(expenseReport.Department, mockEmployee.Department, "Expense department is not equal to employee department"); }
public void Consultant_CreateExpense_ViewData_ExpenseFormViewModal() { //Arrange ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); ExpenseFormViewModel model = new ExpenseFormViewModel(); model.ExpenseItem = new ExpenseItem(); ExpenseReport expenseReport = new ExpenseReport(); expenseReport.CreateDate = DateTime.Now; expenseReport.CreatedBy = mockEmployee; expenseReport.Department = mockEmployee.Department; model.ExpenseReport = expenseReport; //Act var result = controller.CreateExpense(model) as ViewResult; //Assert Assert.AreEqual(model, (ExpenseFormViewModel)result.ViewData.Model, "The view model sent is not the same as what was intialized"); Assert.IsNotNull((ExpenseFormViewModel)result.ViewData.Model, "The resulting view modal is null"); }
public void Consultant_ViewReports_Returns_View_ViewReports() { const string expectedViewName = ""; ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); var result = controller.ViewMyExpenses() as ViewResult; Assert.AreEqual(expectedViewName, result.ViewName, "View names do not match, expected view name is{0}", expectedViewName); }
public void Consultant_ViewReports_Returns_ActionResult() { ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); var result = controller.ViewMyExpenses(); Assert.IsInstanceOfType(result, typeof(ActionResult), "Result is not of ActionResult type"); }
public void Consultant_HttpPost_CreateExpense_Returns_View_CreateExpense() { //Arrange const string expectedViewName = "CreateExpense"; ExpenseFormViewModel expenseForm = new ExpenseFormViewModel(); ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); expenseForm.CreateDate = DateTime.Now; expenseForm.DepartmentName = mockEmployee.Department.DepartmentName; expenseForm.EmployeeName = mockEmployee.Fullname; expenseForm.ExpenseItem = new ExpenseItem(); //Act var result = controller.CreateExpense(expenseForm) as ViewResult; //Assert Assert.AreEqual(expectedViewName, result.ViewName, "View name should have been {0}", expectedViewName); }
public void Consultant_HttpPost_CreateExpense_Returns_ActionResult() { //Arrange ExpenseFormViewModel expenseForm = new ExpenseFormViewModel(); ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); expenseForm.CreateDate = DateTime.Now; expenseForm.DepartmentName = mockEmployee.Department.DepartmentName; expenseForm.EmployeeName = mockEmployee.Fullname; expenseForm.ExpenseItem = new ExpenseItem(); //Act var result = controller.CreateExpense(expenseForm); //Assert Assert.IsInstanceOfType(result, typeof(ActionResult), "The result was not a type of ActionResult"); }
public void Consultant_HttpPost_CreateExpense_AddExpenseItem() { //Arrange ExpenseFormViewModel expenseForm = new ExpenseFormViewModel(); ConsultantController controller = new ConsultantController(mockEmployeeService, mockReportService, mockEmployee); MockHttpContext.SetFakeHttpContext(controller); expenseForm.CreateDate = DateTime.Now; expenseForm.DepartmentName = mockEmployee.Department.DepartmentName; expenseForm.EmployeeName = mockEmployee.Fullname; expenseForm.ExpenseItem = new ExpenseItem(); expenseForm.ExpenseItem.Description = "Laptop"; expenseForm.ExpenseItem.Location = "Sydney Airport"; expenseForm.ExpenseItem.Amount = (decimal)1200.00; expenseForm.ExpenseItem.AudAmount = (decimal)1200.00; expenseForm.ExpenseItem.Currency = "AUD"; //Act ViewResult result = controller.CreateExpense(expenseForm) as ViewResult; ExpenseFormViewModel model = (ExpenseFormViewModel)result.ViewData.Model; //Assert Assert.AreEqual(model.ExpenseItem, expenseForm.ExpenseItem, "Expense items in view are not equal to expense item in the response"); Assert.IsNotNull((ExpenseFormViewModel)result.ViewData.Model, "The resulting view modal is null"); }