public void TestInitialize() { this.timesheetControllerLogger = new Mock <ILogger <TimesheetController> >(); this.telemetryClient = new TelemetryClient(new TelemetryConfiguration()); this.timesheetContext = new Mock <TimesheetContext>(); this.timesheetRepository = new Mock <ITimesheetRepository>(); this.projectRepository = new Mock <IProjectRepository>(); this.repositoryAccessors = new Mock <IRepositoryAccessors>(); this.managerDashboardHelper = new Mock <IManagerDashboardHelper>(); this.mockBotSettings = Options.Create(new BotSettings() { MicrosoftAppId = string.Empty, MicrosoftAppPassword = string.Empty, AppBaseUri = string.Empty, CardCacheDurationInHour = 12, TimesheetFreezeDayOfMonth = 12, WeeklyEffortsLimit = 44, }); this.timesheetHelper = new Mock <ITimesheetHelper>(); this.timesheetController = new TimesheetController(this.timesheetControllerLogger.Object, this.telemetryClient, this.timesheetHelper.Object, this.managerDashboardHelper.Object, this.repositoryAccessors.Object); var httpContext = FakeHttpContext.MakeFakeContext(); this.timesheetController.ControllerContext = new ControllerContext { HttpContext = httpContext, }; }
public void Index_ReturnsIndexViewModelInViewResultTest() { var controller = new TimesheetController(); IActionResult result = controller.Index(Model); Assert.IsType <ViewResult>(result); var viewModel = (result as ViewResult).Model; Assert.IsInstanceOfType <IndexViewModel>(viewModel); }
public void getTimesheet() { // Arrange TimesheetController controller = new TimesheetController(); var actResult = controller.Get(1); // Act var result = actResult as OkNegotiatedContentResult <Timesheet>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content.ID == 1); }
public void DeleteTimesheet() { // Arrange TimesheetController controller = new TimesheetController(); var actResult = controller.Delete(1); // Act var result = actResult as OkNegotiatedContentResult <bool>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content == true); }
protected void Page_Load(object sender, EventArgs e) { TimesheetId = Int32.Parse(Request.Params["id"]); var controller = new TimesheetController(); month.Value = Request.Params["month"]; year.Value = Request.Params["year"]; if (!IsPostBack) { TFS.Intranet.Data.Billing.Timesheet timesheet = new TFS.Intranet.Data.Billing.TimesheetController().FetchByID(TimesheetId)[0]; //check and see if there are any BillingCityRates for this account //var billingCityRateController = new BillingDefaultCityRateController(); //var billingCityRateCol = billingCityRateController.FetchAllActiveByAccountId(timesheet.BillingPeriodAccount.Accountid); //if (billingCityRateCol.Count > 0) //{ //} var timeBillingCityRateJoinController = new TimesheetBillingCityRateJoinController(); var cityCountPerDiem = timeBillingCityRateJoinController.CityPerDiemCountGrandTotalByTimesheetId(TimesheetId); if (cityCountPerDiem > 0) { //hide default per diem count UI element pnlDefaultPerdiemCount.Visible = false; //show city per diem UI elements pnlTimesheetBillingCityRates.Visible = true; DaysPerDiem.Text = cityCountPerDiem.ToString(); } else { DaysPerDiem.Text = timesheet.Perdiemcount.ToString(); } Mileage.Text = timesheet.Mileageclaimed.ToString(); PayRateGroup.Text = timesheet.RateGroup.Name; } }
public void PostTimesheet() { // Arrange TimesheetController controller = new TimesheetController(); Timesheet TimesheetObj = new Timesheet { Project = new Project { ID = 2, Name = "Second" }, Task = new Task { ID = 1, Project = new Project { ID = 1 }, Name = "Development" }, TimesheetGroupID = 1, MondayBNote = "This is sample task for project", TuesdayBNote = "This is sample task for project", WednesdayBNote = "This is sample task for project", ThursdayBNote = "This is sample task for project", FridayBNote = "This is sample task for project", SaturdayBNote = "This is sample task for project", SundayBNote = "This is sample task for project", MondayBTime = new TimeSpan(2, 14, 00), TuesdayBTime = new TimeSpan(2, 14, 00), WednesdayBTime = new TimeSpan(2, 14, 00), ThursdayBTime = new TimeSpan(2, 14, 00), FridayBTime = new TimeSpan(2, 14, 00), SaturdayBTime = new TimeSpan(2, 14, 00), SundayBTime = new TimeSpan(2, 14, 00), MondayNBNote = "This is sample task for project", TuesdayNBNote = "This is sample task for project", WednesdayNBNote = "This is sample task for project", ThursdayNBNote = "This is sample task for project", FridayNBNote = "This is sample task for project", SaturdayNBNote = "This is sample task for project", SundayNBNote = "This is sample task for project", MondayNBTime = new TimeSpan(2, 14, 00), TuesdayNBTime = new TimeSpan(2, 15, 00), WednesdayNBTime = new TimeSpan(2, 16, 00), ThursdayNBTime = new TimeSpan(2, 17, 00), FridayNBTime = new TimeSpan(2, 18, 00), SaturdayNBTime = new TimeSpan(2, 19, 00), SundayNBTime = new TimeSpan(2, 20, 00), MondayDate = new DateTime(2016, 11, 14), TuesdayDate = new DateTime(2016, 11, 15), WednesdayDate = new DateTime(2016, 11, 16), ThursdayDate = new DateTime(2016, 11, 17), FridayDate = new DateTime(2016, 11, 18), SaturdayDate = new DateTime(2016, 11, 19), SundayDate = new DateTime(2016, 11, 20), Status = false, }; var actResult = controller.Post(TimesheetObj); // Act var result = actResult as OkNegotiatedContentResult <Timesheet>; // Assert Assert.IsNotNull(result); Assert.IsTrue(result.Content.ID > 2); }