public async Task InsertTravelAsync_Return_Created_Result(Mock <ITravelService> userService, TravelResponseDto expected) { // Arrange var sut = new TravelController(userService.Object); sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() }; TravelRequestDto requestDto = new TravelRequestDto(); userService.Setup(setup => setup.InsertTravelAsync(requestDto)).Returns(Task.FromResult(expected)); // Act var result = sut.InsertTravelAsync(requestDto); var apiResult = result.Result.Should().BeOfType <CreatedAtActionResult>().Subject; var model = Assert.IsType <ApiResult>(apiResult.Value); TravelResponseDto response = model.Data as TravelResponseDto; // Assert Assert.IsType <CreatedAtActionResult>(result.Result); Assert.IsNotType <OkObjectResult>(result.Result); Assert.IsNotType <BadRequestObjectResult>(result.Result); Assert.IsNotType <AcceptedAtActionResult>(result.Result); Assert.NotNull(result.Result); Assert.NotNull(expected); Assert.IsAssignableFrom <TravelResponseDto>(expected); }
public void TravelWhenTraveling() { // Arrange Mock <CosmoSystem> currentSystemMock = new Mock <CosmoSystem>(); int currentSystemId = 1; currentSystemMock.Expect(m => m.SystemId) .Returns(currentSystemId); Mock <CosmoSystem> targetSystemMock = new Mock <CosmoSystem>(); int targetSystemId = 2; targetSystemMock.Expect(m => m.SystemId) .Returns(targetSystemId); Mock <User> userMock = new Mock <User>(); Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object); managerMock.Expect(m => m.GetSystem(targetSystemId)) .Returns(targetSystemMock.Object) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.CheckIfTraveling()) .Returns(true) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.Travel(targetSystemMock.Object)) .Throws(new InvalidOperationException("InvalidOperationException")) .AtMostOnce() .Verifiable(); // Normal Travel mocks managerMock.Expect(m => m.GetGalaxySize()) .Returns(30) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.JumpDrive.Range) .Returns(12) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.CosmoSystem) .Returns(currentSystemMock.Object) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.GetInRangeSystems()) .Returns(new CosmoSystem[0]) .Verifiable(); managerMock.Expect(m => m.GetSystems()) .Returns(new CosmoSystem[0]) .Verifiable(); TravelController controller = new TravelController(managerMock.Object); // Act ActionResult result = controller.Travel(targetSystemId); // Assert Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view"); ViewResult viewResult = (ViewResult)result; Assert.That(viewResult.ViewName, Is.SubsetOf(new string[] { "", "Travel" }), "Should return the Travel View"); Assert.That(controller.ModelState.IsValid, Is.False, "An error should be returned"); Assert.That(controller.ModelState["_FORM"].Errors[0].ErrorMessage, Is.EqualTo("InvalidOperationException"), "Error for form should be InvalidOperationException"); Assert.That(controller.ViewData["IsTraveling"], Is.True, "The IsTraveling field should be true"); managerMock.Verify(); }
private void InTransitTravelForm_Load(object sender, EventArgs e) { DateTime local_date = DateTime.Now; this.label_fecha.Text = local_date.ToString(); TravelController.FeedDataGridTravelDetails(this.travel_datagrid); }
public async Task FilterTravelAsync_Return_Ok_Result(Mock <ITravelService> travelService, List <TravelResponseDto> expected) { // Arrange var sut = new TravelController(travelService.Object); sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() }; TravelFilterDto dto = new TravelFilterDto(); travelService.Setup(setup => setup.FilterTravelAsync(dto)).Returns(Task.FromResult(expected)); // Act var result = sut.TravelFilterAsync(dto); var apiResult = result.Result.Should().BeOfType <OkObjectResult>().Subject; var model = Assert.IsType <ApiResult>(apiResult.Value); List <TravelResponseDto> response = model.Data as List <TravelResponseDto>; // Assert Assert.IsType <OkObjectResult>(result.Result); Assert.IsNotType <CreatedAtActionResult>(result.Result); Assert.IsNotType <BadRequestObjectResult>(result.Result); Assert.IsNotType <AcceptedAtActionResult>(result.Result); Assert.NotNull(result.Result); Assert.NotNull(expected); Assert.IsAssignableFrom <List <TravelResponseDto> >(expected); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); travelController.Dispose(); expenseController.Dispose(); travelController = null; expenseController = null; }
public void Travel() { // Arrange Mock <CosmoSystem> currentSystemMock = new Mock <CosmoSystem>(); Mock <CosmoSystem> inRangeSystemMock = new Mock <CosmoSystem>(); CosmoSystem[] inRangeSystems = new CosmoSystem[] { inRangeSystemMock.Object }; Mock <CosmoSystem> outOfRangeSystemMock = new Mock <CosmoSystem>(); CosmoSystem[] allSystems = new CosmoSystem[] { currentSystemMock.Object, inRangeSystemMock.Object, outOfRangeSystemMock.Object }; Mock <User> userMock = new Mock <User>(); Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object); managerMock.Expect(m => m.CurrentPlayer.Ship.CheckIfTraveling()) .Returns(false) .Verifiable(); managerMock.Expect(m => m.GetGalaxySize()) .Returns(30) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.JumpDrive.Range) .Returns(12) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.CosmoSystem) .Returns(currentSystemMock.Object) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.GetInRangeSystems()) .Returns(inRangeSystems) .Verifiable(); managerMock.Expect(m => m.GetSystems()) .Returns(allSystems) .Verifiable(); TravelController controller = new TravelController(managerMock.Object); // Act ActionResult result = controller.Travel(); // Assert Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view"); Assert.That(((ViewResult)result).ViewName, Is.SubsetOf(new string[] { "", "Travel" }), "Should return the Travel View"); Assert.That(controller.ModelState.IsValid, "No error should be returned"); Assert.That(controller.ViewData["IsTraveling"], Is.False, "The IsTraveling field should be false"); Assert.That(controller.ViewData["GalaxySize"], Is.EqualTo(30), "The GalaxySize field should be 30"); Assert.That(controller.ViewData["Range"], Is.EqualTo(12), "The Range field should be 12"); Assert.That(controller.ViewData["CurrentSystem"], Is.SameAs(currentSystemMock.Object), "The CurrentSystem field should have a reference to the current system object"); Assert.That(controller.ViewData["InRangeSystems"], Is.EquivalentTo(inRangeSystems), "The InRangeSystems field should have an array containing all the in range systems"); Assert.That(controller.ViewData["Systems"], Is.EquivalentTo(allSystems), "The Systems field should have an array containing all the systems in the galaxy"); managerMock.Verify(); }
public void Index() { // Arrange Mock <User> userMock = new Mock <User>(); Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object); TravelController controller = new TravelController(managerMock.Object); // Act ActionResult result = controller.Index(); // Assert Assert.That(result, Is.TypeOf(typeof(RedirectToRouteResult)), "Should return a redirect"); Assert.That(controller.ModelState.IsValid, "No errors should be returned"); managerMock.Verify(); }
public void TravelInRangeSystem() { // Arrange Mock <CosmoSystem> currentSystemMock = new Mock <CosmoSystem>(); int currentSystemId = 1; currentSystemMock.Expect(m => m.SystemId) .Returns(currentSystemId); Mock <CosmoSystem> targetSystemMock = new Mock <CosmoSystem>(); int targetSystemId = 2; targetSystemMock.Expect(m => m.SystemId) .Returns(targetSystemId); Mock <User> userMock = new Mock <User>(); Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object); managerMock.Expect(m => m.GetSystem(targetSystemId)) .Returns(targetSystemMock.Object) .Verifiable(); managerMock.Expect(m => m.CurrentPlayer.Ship.CheckIfTraveling()) .Returns(false) .Verifiable(); int travelTime = 5; managerMock.Expect(m => m.CurrentPlayer.Ship.Travel(targetSystemMock.Object)) .Returns(travelTime) .AtMostOnce() .Verifiable(); TravelController controller = new TravelController(managerMock.Object); // Act ActionResult result = controller.Travel(targetSystemId); // Assert Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view"); ViewResult viewResult = (ViewResult)result; Assert.That(viewResult.ViewName, Is.EqualTo("TravelInProgress"), "Should return the TravelInProgressView"); Assert.That(controller.ModelState.IsValid, "No error should be returned"); Assert.That(controller.ViewData["IsTraveling"], Is.False, "The IsTraveling field should be false"); Assert.That(controller.ViewData["TravelTime"], Is.EqualTo(travelTime), "The TravelTime field should be 5"); managerMock.Verify(); }
public static void Query() { Console.Clear(); // int serial = 0; string sourceName = string.Empty; string destinationName = string.Empty; Console.WriteLine("Search bus"); Console.WriteLine("-------------"); Console.WriteLine("Please enter Source of your journey: "); sourceName = Console.ReadLine(); Console.WriteLine("Please enter Destination of your journey: "); destinationName = Console.ReadLine(); bool isItemFound = false; foreach (XmlNode node in TravelController.GetXMLNodeList()) { if ((!string.IsNullOrEmpty(sourceName) && node.Attributes[Constant.SOURCE_NAME].Value.ToLower().Contains(sourceName)) && (!string.IsNullOrEmpty(destinationName) && node.Attributes[Constant.DESTINATION_NAME].Value.ToLower().Contains(destinationName))) { if (node.Attributes[Constant.SOURCE_ROUTE_NUMBER].Value == node.Attributes[Constant.DESTINATION_ROUTE_NUMBER].Value) { foreach (XmlNode i in TravelController.GetXMLNodeList()) { if (i.Attributes[Constant.SOURCE_ROUTE_NUMBER].Value == i.Attributes[Constant.ROUTE_NUMBER].Value) { isItemFound = true; Console.WriteLine("\nBus Details"); Console.WriteLine("-------------"); Console.WriteLine("Source Name\t\t: " + i.Attributes[Constant.SOURCE_NAME].Value); Console.WriteLine("Destination Name\t\t: " + i.Attributes[Constant.DESTINATION_NAME].Value); Console.WriteLine("Route Number\t: " + i.Attributes[Constant.ROUTE_NUMBER].Value); Console.WriteLine("Availability\t: " + i.Attributes[Constant.AVAILABLE_SEATS].Value); Console.WriteLine("Bus Fare\t: " + i.Attributes[Constant.BUS_FARE].Value); } } } } } if (!isItemFound) { Console.WriteLine("Oops, No book is found under the given serial number"); } }
public async Task PassiveTravelAsync_Return_NoContent_Result(Mock <ITravelService> travelService) { var sut = new TravelController(travelService.Object); sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() }; travelService.Setup(setup => setup.PassiveTravelAsync(travelId)); // Act var result = sut.PassiveTravelAsync(travelId); // Assert Assert.IsType <NoContentResult>(result.Result); Assert.IsNotType <OkObjectResult>(result.Result); Assert.IsNotType <CreatedAtActionResult>(result.Result); Assert.IsNotType <BadRequestObjectResult>(result.Result); Assert.IsNotType <AcceptedAtActionResult>(result.Result); }
public virtual void InitWelcomeScreen() { TravelController.Init(); Console.WriteLine("\n\nWelcome to Travel Manager\n"); Console.WriteLine("\n\nKindly select the your user type\n"); Console.WriteLine("1 - Admin"); Console.WriteLine("2 - Guest User"); int selection = Utils.OptionSelection(2); TravelController.Init(); switch (selection) { case 1: Console.WriteLine("\n**** Authentication is required for Admin mode****"); AdminView.Display(); break; case 2: MainMenuView.Display(); break; } }
static void Main(string[] args) { int choice; do { Console.Clear(); Console.WriteLine("=======MENU======="); Console.WriteLine("1. User"); Console.WriteLine("2. Role"); Console.WriteLine("3. Departments"); Console.WriteLine("4. Type"); Console.WriteLine("5. Category"); Console.WriteLine("6. Travel"); Console.WriteLine("7. Hotel Cost"); Console.WriteLine("8. Transport Cost"); Console.WriteLine("9. Exit"); Console.WriteLine("=================="); Console.Write("Pilih Action : "); choice = Convert.ToInt32(System.Console.ReadLine()); switch (choice) { case 1: UserController callUser = new UserController(); callUser.Menu(); break; case 2: RoleController callRole = new RoleController(); callRole.Menu(); break; case 3: DepartmentController callDepartments = new DepartmentController(); callDepartments.Menu(); break; case 4: TypeController callType = new TypeController(); callType.Menu(); break; case 5: CategoryController callCategory = new CategoryController(); callCategory.Menu(); break; case 6: TravelController callTravel = new TravelController(); callTravel.Menu(); break; case 7: HotelCostController callHotelCost = new HotelCostController(); callHotelCost.Menu(); break; case 8: TransportController callTransprotCost = new TransportController(); callTransprotCost.Menu(); break; default: System.Console.Write("Exit Cuy!"); System.Console.Read(); break; } } while (choice != 9); }
public TravelExpenseController(ControllerObject controller) : base(controller) { travelController = new TravelController(this); expenseController = new ExpenseController(this); }
public TravelExpenseController(IContext context) : base(context) { travelController = new TravelController(this); expenseController = new ExpenseController(this); }
public ScheduledTravelForm() { InitializeComponent(); TravelController.FeedDataGridScheduledTravels(dataGridView1); }
protected void Application_Start() { objFileLog.WriteLine(LogType.Info, "App start", "Global.asax", "App_Start", string.Empty); XmlConfigurator.Configure(); log.Info("Vibrant Web Application started."); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine()); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); //timer.AutoReset = true; //timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); //timer.Enabled = true; var SEM = new SEMController(); SEM.SetTimerValue(); //Resource Allocation Auto mail var resource = new ResourceController(); // resource.SetTimerValue(); var travel = new TravelController(); travel.SetTimerValue(); //Confirmation Process Auto mail var Confirmation = new ConfirmationProcessController(); Confirmation.SetTimerValue(); Application["LeaveBalanceWF"] = ""; Application["AttendanceWF"] = ""; Application["LeaveUpLoadWF"] = ""; Application["WokflowRuntime"] = ""; var workflowRuntime = Application["WokflowRuntime"] as WorkflowRuntime; if (workflowRuntime == null) { workflowRuntime = new WorkflowRuntime(); workflowRuntime.WorkflowIdled += workflowRuntime_WorkflowIdled; workflowRuntime.WorkflowLoaded += workflowRuntime_WorkflowLoaded; workflowRuntime.WorkflowUnloaded += workflowRuntime_WorkflowUnloaded; workflowRuntime.WorkflowPersisted += workflowRuntime_WorkflowPersisted; workflowRuntime.WorkflowCompleted += delegate { }; workflowRuntime.WorkflowTerminated += delegate(object sender1, WorkflowTerminatedEventArgs e1) { Debug.WriteLine(e1.Exception.Message); }; // Add the Persistance Service //WorkflowPersistenceService workflowPersistanceService = new SqlWorkflowPersistenceService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); //workflowRuntime.AddService(workflowPersistanceService); WorkflowSchedulerService workflowSchedulerService = new DefaultWorkflowSchedulerService(); workflowRuntime.AddService(workflowSchedulerService); //System.Workflow.Runtime.Hosting. SqlTrackingService trackingService = new SqlTrackingService(connectionString2); //System.Workflow.Runtime.Tracking.SqlTrackingService workflowTrackingService = new System.Workflow.Runtime.Tracking.SqlTrackingService(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); //workflowRuntime.AddService(workflowTrackingService); // Add the External Data Exchange Service var dataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchangeService); LeaveBalanceService objLeaveBalanceService; LeaveDetailsService objLeaveDetailsService; OutOfOfficeService objOutOfOfficeService; CompensationService objCompensationService; SignInSignOutService objSignInSignOutService; AttendanceCheckerService objAttendanceCheckerService; LeaveUploadService objLeaveUploadService; // Add a new instance of the LeaveBalanceService to the External Data Exchange Service objLeaveBalanceService = new LeaveBalanceService(); objLeaveDetailsService = new LeaveDetailsService(); objOutOfOfficeService = new OutOfOfficeService(); objCompensationService = new CompensationService(); objSignInSignOutService = new SignInSignOutService(); objAttendanceCheckerService = new AttendanceCheckerService(); objLeaveUploadService = new LeaveUploadService(); //Adding our services to ExternalDataExchangeService dataExchangeService.AddService(objLeaveBalanceService); dataExchangeService.AddService(objLeaveDetailsService); dataExchangeService.AddService(objOutOfOfficeService); dataExchangeService.AddService(objCompensationService); dataExchangeService.AddService(objSignInSignOutService); dataExchangeService.AddService(objAttendanceCheckerService); dataExchangeService.AddService(objLeaveUploadService); // Start the Workflow services //workflowRuntime.UnloadOnIdle = true; workflowRuntime.StartRuntime(); Application["WokflowRuntime"] = workflowRuntime; //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime; //System.Web.HttpContext.Current.Cache["WokflowRuntime"]=workflowRuntime; objFileLog.WriteLine(LogType.Info, "App start finished", "Global.asax", "App_Start", string.Empty); } }
partial void Constructed() { travelController = new TravelController(this); expenseController = new ExpenseController(this); }
static void Main(string[] args) { TravelController travelController = new TravelController(); }