public void RentCarAtCrossedUsedTime_Exception() { var clientFacade = new ClientFacade("Bob"); var carFacade1 = new CarFacade("Audi"); var carFacade2 = new CarFacade("BMW"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 11, 06)); var date3 = new DateTimeOffset(new DateTime(2018, 10, 19)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date1, date3); clientFacade.RentCar(carFacade1, time1); bool hasException = false; try { clientFacade.RentCar(carFacade2, time2); } catch (Exception) { hasException = true; } Assert.IsTrue(hasException); }
private void button2_Click(object sender, EventArgs e) { string textToSubmit = this.richTextBox2.Text; ClientFacade facade = new ClientFacade(); Team team = new Team() { Id = 1, Name = "Team01", Password = "******" }; team = facade.AuthenticateTeam(team); Submit submit = new Submit(); submit.Team = team; submit.Data = new UTF8Encoding().GetBytes(textToSubmit); submit.AssignmentEnrollment = new AssignmentEnrollment() { Id = 1, Team = team }; submit.TournamentAssignment = new TournamentAssignment() { Id = 1 }; submit.SubmitDate = DateTime.Now; submit.FileName = "HelloWorld.cs"; facade.SaveSubmit(submit); }
public virtual void TearDown() { Facade.SetApplication(null); ClientFacade.SetApplication(null); App.Dispose(); }
public void RentTwoCarsByOnClient_TwoCarsInRentHistory() { var clientFacade = new ClientFacade("Bob"); var carFacade1 = new CarFacade("Audi"); var carFacade2 = new CarFacade("BMW"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 11, 06)); var date3 = new DateTimeOffset(new DateTime(2018, 11, 10)); var date4 = new DateTimeOffset(new DateTime(2018, 11, 19)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date3, date4); clientFacade.RentCar(carFacade1, time1); clientFacade.RentCar(carFacade2, time2); var listOfRent = clientFacade.Client.RentHistory.ToList(); Assert.AreEqual(listOfRent[0].Value, carFacade1); Assert.AreEqual(listOfRent[0].Key.StartTime, time1.StartTime); Assert.AreEqual(listOfRent[0].Key.EndTime, time1.EndTime); Assert.AreEqual(listOfRent[1].Value, carFacade2); Assert.AreEqual(listOfRent[1].Key.StartTime, time2.StartTime); Assert.AreEqual(listOfRent[1].Key.EndTime, time2.EndTime); }
public override void OnActionExecuting(HttpActionContext actionContext) { base.OnActionExecuting(actionContext); string tokenkey = "centisoft_token"; HttpResponseMessage responseMessage = new HttpResponseMessage(); IClientFacade clientFacade = new ClientFacade(); Client client = null; if (actionContext.Request.Headers.Contains(tokenkey)) { IEnumerable <string> headerValue = actionContext.Request.Headers.GetValues(tokenkey); string token = headerValue.FirstOrDefault(); client = clientFacade.LoadClient(token); if (client == null) { responseMessage.StatusCode = HttpStatusCode.Forbidden; responseMessage.ReasonPhrase = "Token is invalid"; } else { responseMessage.StatusCode = HttpStatusCode.OK; responseMessage.ReasonPhrase = "Token Valid"; responseMessage.Content = new StringContent(client.Id.ToString()); actionContext.Request.Properties.Add(new KeyValuePair <string, object>("id", client.Id)); } } else { responseMessage.StatusCode = HttpStatusCode.Forbidden; responseMessage.ReasonPhrase = "No token in header"; } }
public IClientController CreateClientController() { IClientController controller = null; ClientFacade facade = new ClientFacade(factory); switch (loginType) { case LoginType.Client: controller = new ClientClientController(factory, facade); break; case LoginType.Superuser: controller = new SuperuserClientController(factory, facade); break; case LoginType.Bookmaker: controller = new BookmakerClientController(factory, facade); break; default: break; } return(controller); }
private void _timer_Elapsed(object sender, ElapsedEventArgs e) { ClientFacade facade = new ClientFacade(); List <Submit> submits = facade.GetUnprocessedSubmits(); StartNewSubmits(submits); TerminateOldSubmits(); TraceStatus(); }
public override void Dispose() { base.Dispose(); ClientFacade.UnsetIfEqualsGiven(this); // NOTE: the game object will be destroyed by Unity GameObject = null; }
public void RentCar_CarInRentHistory() { var clientFacade = new ClientFacade("Bob"); var carFacade = new CarFacade("Audi"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 11, 06)); var time = new RentTime(date1, date2); clientFacade.RentCar(carFacade, time); Assert.AreEqual(carFacade, clientFacade.Client.RentHistory.First().Value); }
public void RentCar10Times_CarAtService() { var carRentCompanyFacade = new CarRentCompanyFacade(); var carFacade = new CarFacade("10"); var clientFacade = new ClientFacade("Bob"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 10, 07)); var date3 = new DateTimeOffset(new DateTime(2018, 10, 08)); var date4 = new DateTimeOffset(new DateTime(2018, 10, 09)); var date5 = new DateTimeOffset(new DateTime(2018, 10, 10)); var date6 = new DateTimeOffset(new DateTime(2018, 10, 11)); var date7 = new DateTimeOffset(new DateTime(2018, 10, 12)); var date8 = new DateTimeOffset(new DateTime(2018, 10, 13)); var date9 = new DateTimeOffset(new DateTime(2018, 10, 14)); var date10 = new DateTimeOffset(new DateTime(2018, 10, 15)); var date11 = new DateTimeOffset(new DateTime(2018, 10, 16)); var date12 = new DateTimeOffset(new DateTime(2018, 10, 17)); var date13 = new DateTimeOffset(new DateTime(2018, 10, 18)); var date14 = new DateTimeOffset(new DateTime(2018, 10, 19)); var date15 = new DateTimeOffset(new DateTime(2018, 10, 20)); var date16 = new DateTimeOffset(new DateTime(2018, 10, 21)); var date17 = new DateTimeOffset(new DateTime(2018, 10, 22)); var date18 = new DateTimeOffset(new DateTime(2018, 10, 23)); var date19 = new DateTimeOffset(new DateTime(2018, 10, 24)); var date20 = new DateTimeOffset(new DateTime(2018, 10, 25)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date3, date4); var time3 = new RentTime(date5, date6); var time4 = new RentTime(date7, date8); var time5 = new RentTime(date9, date10); var time6 = new RentTime(date11, date12); var time7 = new RentTime(date13, date14); var time8 = new RentTime(date15, date16); var time9 = new RentTime(date17, date18); var time10 = new RentTime(date19, date20); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time1); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time2); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time3); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time4); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time5); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time6); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time7); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time8); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time9); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time10); carRentCompanyFacade.SendCarOnService(carFacade, time10.EndTime.AddDays(1)); Assert.AreEqual(carFacade.Car.Services.Count, 1); Assert.AreEqual(carFacade.Car.CountToService, 0); }
public void StartWatching() { ClientFacade facade = new ClientFacade(); List <Submit> submits = facade.GetUnprocessedSubmits(); //start watching new submits StartNewSubmits(submits); //set the timer to start periodically watching _timer = new System.Timers.Timer(); _timer.Interval = GetPollingInterval(); _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _timer.Start(); }
private static void SaveStatusToDatabase(Submit submit, ValidationResult result) { string teamName = submit.Team.Name; string assignmentName = submit.TournamentAssignment.Assignment.Name; string details = ""; foreach (string detail in result.Messages) { details += detail; } if (details.Length > 1000) { details = details.Substring(0, 999); } ClientFacade facade = new ClientFacade(); //process result switch (result.Status) { case SubmitStatusCode.Unknown: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorUnknown, details, DateTime.Now); break; case SubmitStatusCode.CompilationError: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorCompilation, details, DateTime.Now); break; case SubmitStatusCode.ValidationError: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorValidation, details, DateTime.Now); break; case SubmitStatusCode.TestError: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorTesting, details, DateTime.Now); break; case SubmitStatusCode.ServerError: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorServer, details, DateTime.Now); break; case SubmitStatusCode.Success: facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Success, details, DateTime.Now); break; default: break; } }
public void SendCarOnService_CarOnService() { var carRentFacade = new CarRentCompanyFacade(); var clientFacade = new ClientFacade("Bob"); var carFacade = new CarFacade("Lava Kavina"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 07)); var date2 = new DateTimeOffset(new DateTime(2018, 11, 07)); var time = new RentTime(date1, date2); carRentFacade.CarRentCompany.CarRepository.Create(carFacade.Car); carRentFacade.SendCarOnService(carFacade, time.StartTime); Assert.AreEqual(carRentFacade.CarRentCompany.CarRepository.GetItem(0).IsAtServiceAt(time), true); }
public static void Main(string[] args) { //var testArgs = new[] { "-i", @"D:\deploy\project", "-n", "TESTRUN2" }; var options = new OptionsParser(); var serviceData = options.Parse(args); if (serviceData == null) { return; } var client = new ClientFacade( ConfigurationManager.AppSettings["login"], ConfigurationManager.AppSettings["password"], serviceData); try { if (client.OpenSession()) { Console.WriteLine("Connection to service is established. Connection session is opened."); client.SendFiles(); client.Deploy(); } else { Console.WriteLine("Connection was terminated because folder '{0}' is already is use.", serviceData.Directory); client.Close(); ClientFacade.NeedClose = true; } } catch (Exception ex) { HandleException(ex); client.Abort(); ClientFacade.NeedClose = true; } while (ClientFacade.NeedClose != true) { Thread.Sleep(500); } Console.WriteLine("\r\nPress any key to close..."); Console.ReadKey(); }
public void HasCarAt_False() { var answer = false; var clientFacade = new ClientFacade("Bob"); var carFacade = new CarFacade("Audi"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 11, 06)); var date3 = new DateTimeOffset(new DateTime(2018, 11, 10)); var date4 = new DateTimeOffset(new DateTime(2022, 01, 13)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date3, date4); clientFacade.RentCar(carFacade, time1); var hasCar = clientFacade.HasCarAt(time2); Assert.AreEqual(answer, hasCar); }
public void RentLotsOfCars_ClientsWithRentHistory() { var clientFacade1 = new ClientFacade("Bob"); var carFacade1 = new CarFacade("1"); var carFacade2 = new CarFacade("2"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 10, 10)); var date3 = new DateTimeOffset(new DateTime(2018, 10, 30)); var date4 = new DateTimeOffset(new DateTime(2018, 11, 02)); var date5 = new DateTimeOffset(new DateTime(2018, 12, 01)); var date6 = new DateTimeOffset(new DateTime(2018, 12, 31)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date3, date4); var time3 = new RentTime(date5, date6); var clientFacade2 = new ClientFacade("Alice"); var carFacade3 = new CarFacade("3"); var carFacade4 = new CarFacade("4"); var carFacade5 = new CarFacade("5"); var carFacade6 = new CarFacade("6"); var date7 = new DateTimeOffset(new DateTime(2018, 10, 15)); var date8 = new DateTimeOffset(new DateTime(2018, 11, 30)); var date9 = new DateTimeOffset(new DateTime(2018, 12, 06)); var date10 = new DateTimeOffset(new DateTime(2018, 12, 27)); var date11 = new DateTimeOffset(new DateTime(2019, 03, 01)); var date12 = new DateTimeOffset(new DateTime(2019, 04, 14)); var date13 = new DateTimeOffset(new DateTime(2019, 11, 10)); var date14 = new DateTimeOffset(new DateTime(2020, 11, 19)); var time4 = new RentTime(date7, date8); var time5 = new RentTime(date9, date10); var time6 = new RentTime(date11, date12); var time7 = new RentTime(date13, date14); clientFacade1.RentCar(carFacade1, time1); clientFacade1.RentCar(carFacade2, time2); clientFacade1.RentCar(carFacade1, time3); clientFacade2.RentCar(carFacade3, time4); clientFacade2.RentCar(carFacade4, time5); clientFacade2.RentCar(carFacade5, time6); clientFacade2.RentCar(carFacade6, time7); Assert.AreEqual(clientFacade1.GetHistory().Count, 3); Assert.AreEqual(clientFacade2.GetHistory().Count, 4); }
private static void ProcessTeamSubmit(ValidationProcess validationProcess, SystemSettings sysSettings) { Submit submit = validationProcess.Submit; string teamName = submit.Team.Name; string assignmentName = submit.TournamentAssignment.Assignment.Name; Log(string.Format("Processing teamsubmit {0} for assignment {1}", teamName, assignmentName)); //create the processor SubmitValidator validator = new SubmitValidator(new MoCS.BuildService.Business.FileSystemWrapper(), new ExecuteCmd()); validationProcess.SetProcessor(validator); //prepare directory and files for processing string teamSubmitDirName = CreateTeamDirectory(sysSettings, teamName, submit.TournamentAssignment.Assignment); ClientFacade facade = new ClientFacade(); MoCS.Business.Objects.Assignment assignment = facade.GetAssignmentById(submit.TournamentAssignment.Assignment.Id, true); CopyFiles(assignment, submit, teamSubmitDirName, sysSettings); //START PROCESSING //settings that are read from the assignment AssignmentSettings assignmentSettings = SettingsFactory.CreateAssignmentSettings(assignment, assignmentName); //settings that are from the submitprocess/team submit SubmitSettings submitSettings = SettingsFactory.CreateSubmitSettings(teamName, teamSubmitDirName, assignmentName); //set status of submit to 'processing' facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Processing, "This submitted is currently processed.", DateTime.Now); ValidationResult result = validator.Process(sysSettings, assignmentSettings, submitSettings); validationProcess.Result = result; Log(result.Status + " for " + submit.Team.Name + " on " + submit.TournamentAssignment.Assignment.Name); //save the new status to the database SaveStatusToDatabase(validationProcess.Submit, result); // Delete nunit.framework.dll from the submit dir to keep things clean CleanupFiles(teamSubmitDirName); }
static void Main(string[] args) { ClientFacade clientFacade = new ClientFacade(); ServerFacade serverFacade = new ServerFacade(clientFacade); IServerController serverController = new ServerController(serverFacade); IServer server = new ServerSocket(serverController); serverFacade.Init(serverController); clientFacade.Init(serverController); Task.Run(() => server.Start()); while (Console.ReadLine().ToLower() != "stop") { ; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); //FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab); //fab.Click += FabOnClick; this.actionText = FindViewById<TextView>(Resource.Id.actionText); this.xText = FindViewById<TextView>(Resource.Id.xText); this.yText = FindViewById<TextView>(Resource.Id.yText); this.connectivityBar = FindViewById<LinearLayout>(Resource.Id.connectivityBar); this.serverText = FindViewById<TextView>(Resource.Id.serverText); this.connectionText = FindViewById<TextView>(Resource.Id.connectionText); var mouseController = FindViewById<RelativeLayout>(Resource.Id.mouse_controller); DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); mouseController.SetOnTouchListener(this); mouseController.Clickable = true; mouseController.Focusable = true; ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawer.AddDrawerListener(toggle); toggle.SyncState(); NavigationView navigationView = FindViewById<NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); this.client = new ClientFacade(); this.client.ServerDiscovery += Client_ServerDiscovery; this.client.ConnectionStateChange += Client_ConnectionStateChange; this.client.DiscoverAndConnect(); }
public virtual void SetUp() { // create testing client application ClientApp = new ClientApplication( UnisavePreferences.LoadOrCreate() ); // prepare environment var env = new EnvStore(); DownloadEnvFile(env); // create testing backend application App = Bootstrap.Boot( GetGameAssemblyTypes(), env, new SpecialValues() ); // execute backend code locally ClientApp.Singleton <FacetCaller>( _ => new TestingFacetCaller(App, ClientApp) ); // logging should go direct, we don't want to wait for app disposal // for writing logs to special values // HACK: this is a hack, see the ClientSideLog class for more App.Singleton <ILog>(_ => new ClientSideLog()); // bind facades Facade.SetApplication(App); ClientFacade.SetApplication(ClientApp); // start with a blank slate ClientApp.Resolve <ClientSessionIdRepository>().StoreSessionId(null); ClearDatabase(); }
public ClientController() { this.clientFacade = new ClientFacade(); }
void OnDestroy() { ClientFacade.SetApplication(null); }
void OnDisable() { ClientFacade.SetApplication(null); }
// used if awake is not called // e.g. after compilation // UnisaveServer makes sure no duplicate overriding takes place void OnEnable() { ClientFacade.SetNewFromPreferences(preferences); }
void Awake() { ClientFacade.SetNewFromPreferences(preferences); }
public UserController(UserFacade facade, ClientFacade clientFacade) { _userFacade = facade; _clientFacade = clientFacade; }
public void SendCarOnRent11Times_Exception() { var carRentCompanyFacade = new CarRentCompanyFacade(); var carFacade = new CarFacade("10"); var clientFacade = new ClientFacade("Bob"); var date1 = new DateTimeOffset(new DateTime(2018, 10, 06)); var date2 = new DateTimeOffset(new DateTime(2018, 10, 07)); var date3 = new DateTimeOffset(new DateTime(2018, 10, 08)); var date4 = new DateTimeOffset(new DateTime(2018, 10, 09)); var date5 = new DateTimeOffset(new DateTime(2018, 10, 10)); var date6 = new DateTimeOffset(new DateTime(2018, 10, 11)); var date7 = new DateTimeOffset(new DateTime(2018, 10, 12)); var date8 = new DateTimeOffset(new DateTime(2018, 10, 13)); var date9 = new DateTimeOffset(new DateTime(2018, 10, 14)); var date10 = new DateTimeOffset(new DateTime(2018, 10, 15)); var date11 = new DateTimeOffset(new DateTime(2018, 10, 16)); var date12 = new DateTimeOffset(new DateTime(2018, 10, 17)); var date13 = new DateTimeOffset(new DateTime(2018, 10, 18)); var date14 = new DateTimeOffset(new DateTime(2018, 10, 19)); var date15 = new DateTimeOffset(new DateTime(2018, 10, 20)); var date16 = new DateTimeOffset(new DateTime(2018, 10, 21)); var date17 = new DateTimeOffset(new DateTime(2018, 10, 22)); var date18 = new DateTimeOffset(new DateTime(2018, 10, 23)); var date19 = new DateTimeOffset(new DateTime(2018, 10, 24)); var date20 = new DateTimeOffset(new DateTime(2018, 10, 25)); var date21 = new DateTimeOffset(new DateTime(2018, 10, 26)); var date22 = new DateTimeOffset(new DateTime(2018, 10, 27)); var time1 = new RentTime(date1, date2); var time2 = new RentTime(date3, date4); var time3 = new RentTime(date5, date6); var time4 = new RentTime(date7, date8); var time5 = new RentTime(date9, date10); var time6 = new RentTime(date11, date12); var time7 = new RentTime(date13, date14); var time8 = new RentTime(date15, date16); var time9 = new RentTime(date17, date18); var time10 = new RentTime(date19, date20); var time11 = new RentTime(date21, date22); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time1); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time2); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time3); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time4); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time5); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time6); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time7); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time8); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time9); carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time10); bool hasException = false; try { carRentCompanyFacade.SendCarOnRent(carFacade, clientFacade.Client, time11); } catch (Exception) { hasException = true; } Assert.IsTrue(hasException); }