public void CalculateTest() { LocationInput locationInput = new LocationInput(); locationInput.Sliding = "Sliding 4"; Input input = new Input { Set = 1, HargaKainA = 12, Lebar = 120, Tinggi = 110, HargaCincin = 11.2, Layout = "T", Location = locationInput }; //string jsonOutput = JsonSerializer.Serialize(input); IFormula formula = new F1_1(); Output actual = formula.Calculate(input); Assert.AreEqual(actual.Jumlah, 263.31); Assert.AreEqual(actual.HargaKainA, 192.31); Assert.AreEqual(actual.Keping, 5); Assert.AreEqual(actual.TailorKeping, 2.5); Assert.AreEqual(actual.TailorMeterA, 3.08); Assert.AreEqual(actual.TailorKepingA, 5); Assert.AreEqual(actual.TailorTotalKeping, 5); Assert.AreEqual(actual.UpahKainA, 15); Assert.AreEqual(actual.UpahCincin, 56); }
void ReleaseDesignerOutlets() { if (TitleInput != null) { TitleInput.Dispose(); TitleInput = null; } if (AuthorInput != null) { AuthorInput.Dispose(); AuthorInput = null; } if (GenreInput != null) { GenreInput.Dispose(); GenreInput = null; } if (ISBNInput != null) { ISBNInput.Dispose(); ISBNInput = null; } if (LocationInput != null) { LocationInput.Dispose(); LocationInput = null; } }
public void LocationInput_ToLocation_ShouldMapProperly() { //Arrange var mapper = MockMapper(); var locationInput = new LocationInput { Name = "Amos", Latitude = -43.0987, Longitude = 127.6782, Country = "CA", AdministrativeRegion = "10", Population = 25000 }; //Act var mapped = mapper.Map <Location>(locationInput); //Assert mapped.ShouldSatisfyAllConditions( () => mapped.Name.ShouldBe("Amos"), () => mapped.Latitude.ShouldBe(-43.0987), () => mapped.Longitude.ShouldBe(127.6782), () => mapped.Country.ShouldBe("Canada"), () => mapped.AdministrativeRegion.ShouldBe("QC"), () => mapped.Population.ShouldBe(25000) ); }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { var dialog = new FolderSelectDialog { InitialDirectory = Directory.GetCurrentDirectory(), Title = "Select your Beat Saber game folder." }; if (dialog.Show()) { WindowViewModel.NewLocationInput = dialog.FileName; LocationInput.Focus(); } }
// Changes to make project more like this: https://dev.to/michaelstaib/get-started-with-hot-chocolate-and-entity-framework-e9i /// <summary> /// Gets all students. /// </summary> public async Task <Locations> AddLocation([Service] MyDbContext dbContext, LocationInput input) { var tempInput = new Entities.Locations { Name = input.Name, Code = input.Code, Active = input.Active }; dbContext.Location.Add(tempInput); dbContext.SaveChanges(); // TODO figure out how to get the ID # and assign back to the entity? // tempInput.ID = dbContext.Location. return(tempInput); }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { btnBrowse.IsEnabled = false; string dir = WindowViewModel.NewLocationInput; if (dir == null || dir.Length == 0 || !Directory.Exists(dir)) { dir = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"; } var dialog = new FolderSelectDialog { InitialDirectory = dir, Title = "Select your Beat Saber game folder." }; if (dialog.Show(InteropHelper.Handle)) { WindowViewModel.NewLocationInput = dialog.FileName; LocationInput.Focus(); } btnBrowse.IsEnabled = true; }
private void DisplayLocationInputWindow(LocationInputViewModel locationWindowControl) { var locationWindow = new LocationInput(locationWindowControl); locationWindow.ShowDialog(); }
public MainForm() { InitializeComponent(); Load += async(s, e) => { if (GetRegistry("autorun") == null) { SetRegistry("autorun", "True"); } if (GetRegistry("autorun") == "True") { SettingsAutoRun.Checked = true; String[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { if (args[1] == "/minimized") { // костыль ебаный! await Task.Delay(10); WindowState = FormWindowState.Minimized; Hide(); } } } else { SettingsAutoRun.Checked = false; } }; Resize += (s, e) => { if (WindowState == FormWindowState.Minimized) { Hide(); Tray.Visible = true; } else if (FormWindowState.Normal == WindowState) { Tray.Visible = false; } }; KeyDown += (s, e) => { if (e.KeyCode == Keys.Escape && !SettingPanel.Visible) { LocMessage.ForeColor = SystemColors.ControlDarkDark; e.SuppressKeyPress = true; LocationInput.Text = GetRegistry("location"); LocationInput.SelectAll(); LocationInput.Focus(); } }; TitleBar.MouseDown += (s, e) => { TitleBar.Capture = false; Message m = Message.Create(Handle, 161, new IntPtr(2), IntPtr.Zero); WndProc(ref m); }; MinimizeButton.Click += (s, e) => { WindowState = FormWindowState.Minimized; }; CloseButton.Click += (s, e) => { Close(); }; CloseButton.MouseMove += (s, e) => { CloseButton.BackColor = Color.FromArgb(255, 38, 60); CloseButton.Image = Properties.Resources.close_white; }; CloseButton.MouseLeave += (s, e) => { CloseButton.BackColor = SystemColors.Control; CloseButton.Image = Properties.Resources.close_gray; }; SettingButton.Click += (s, e) => { if (AboutPanel.Visible) { AboutPanel.Visible = false; AboutButton.BackColor = SystemColors.Control; } SettingPanel.Visible = !SettingPanel.Visible; SettingButton.BackColor = SettingPanel.Visible ? SystemColors.ControlLight : SystemColors.Control; }; AboutButton.Click += (s, e) => { if (SettingPanel.Visible) { SettingPanel.Visible = false; SettingButton.BackColor = SystemColors.Control; } AboutPanel.Visible = !AboutPanel.Visible; AboutButton.BackColor = AboutPanel.Visible ? SystemColors.ControlLight : SystemColors.Control; }; Tray.MouseClick += (s, e) => { if (e.Button == MouseButtons.Left) { Show(); Tray.Visible = false; WindowState = FormWindowState.Normal; FadeInApp(); } }; TrayAboutButton.Click += (s, e) => { Show(); Tray.Visible = false; WindowState = FormWindowState.Normal; FadeInApp(); if (!AboutPanel.Visible) { AboutButton.Focus(); SendKeys.Send(" "); } }; TraySettingsButton.Click += (s, e) => { Show(); Tray.Visible = false; WindowState = FormWindowState.Normal; FadeInApp(); if (!SettingPanel.Visible) { SettingButton.Focus(); SendKeys.Send(" "); } }; TrayCloseButton.Click += (s, e) => { Close(); }; LocationInput.Enter += (s, e) => { isEntered = true; LocMessage.Text = "Нажмите Enter, чтобы сохранить."; }; LocationInput.KeyDown += (s, e) => { if (e.KeyCode == Keys.Enter) { ActiveControl = null; e.SuppressKeyPress = true; GetWeather((s as TextBox).Text); } }; LocationInput.KeyPress += (s, e) => { RegExpLocationInput(s, e); }; LocationInput.TextChanged += (s, e) => { int i = LocationInput.TextLength; if (i >= 25) { LocationInput.Font = new Font("Segoe UI Semibold", 16.75F); LocationInput.Location = new Point(11, 15); } else if (i >= 20) { LocationInput.Location = new Point(11, 10); LocationInput.Font = new Font("Segoe UI Semibold", 18.75F); } else if (i >= 15) { LocationInput.Location = new Point(11, 6); LocationInput.Font = new Font("Segoe UI Semibold", 20.75F); } else { LocationInput.Location = new Point(11, 3); LocationInput.Font = new Font("Segoe UI Semibold", 27.75F); } }; SettingsLocation.KeyPress += (s, e) => { RegExpLocationInput(s, e); }; SettingsApiKey.Enter += (s, e) => { SettingsApiKey.PasswordChar = '\0'; }; SettingsApiKey.Leave += (s, e) => { SettingsApiKey.PasswordChar = '●'; }; SettingsApiKey.KeyPress += (s, e) => { char k = e.KeyChar; if (!char.IsControl(k) && !char.IsNumber(k) && (k <= 96 || k >= 193)) { e.Handled = true; } }; SettingsRunPath.Text = exPath; SettingsAutoRun.CheckedChanged += (s, e) => { bool check = (s as CheckBox).Checked; if (check) { SetRegistry("autorun", "True"); using (RegistryKey r = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) r.SetValue(appName, exPath + " /minimized"); } else { SetRegistry("autorun", "False"); using (RegistryKey r = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true)) r.DeleteValue(appName); } }; SettingsInterval.KeyPress += (s, e) => { char k = e.KeyChar; if (!char.IsControl(k) && !char.IsNumber(k)) { e.Handled = true; } }; SettingsSaveButton.Click += (s, e) => { var b = (s as Button); b.Enabled = false; if (SettingsInterval.Text != "0") { SetRegistry("interval", SettingsInterval.Text); Timer.Interval = Convert.ToInt32(SettingsInterval.Text) * 60000; SettingsInterval.ForeColor = SystemColors.ControlDarkDark; } else { SettingsInterval.ForeColor = Color.Firebrick; } SetRegistry("api", SettingsApiKey.Text); GetWeather(SettingsLocation.Text); b.Enabled = true; }; SettingsRestoreButton.Click += (s, e) => { using (RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"Software\" + appName)) { if (reg != null) { Registry.CurrentUser.DeleteSubKey(@"Software\" + appName); } } using (RegistryKey run = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run")) { if (run.GetValue(appName) != null) { run.DeleteValue(appName); } SetRegistry("autorun", "True"); SettingsAutoRun.Checked = true; } InitializeApp(); }; ReconnectButton.Click += (s, e) => { ReconnectButton.Text = "Подключаюсь..."; ReconnectButton.Enabled = false; InitializeApp(); }; AboutAppName.Text = appName; AboutAppVer.Text = $"Версия {About.AssemblyVersion}"; AboutAppDesc.Text = About.AssemblyDescription; openGitHub.Click += (s, e) => { Process.Start("https://github.com/crashmax-dev/WeatherCS"); }; GetAPIButton.Click += (s, e) => { Process.Start("https://openweathermap.org/appid"); }; AboutCheckUpdates.Click += (s, e) => { var b = (s as Button); b.Enabled = false; CheckForUpdates(); }; InitializeApp(); }
public void SearchActions() { //Variable Declarations //WebElement for Location TextBox IWebElement LocationInput; //Web Elements for the Check-in and Check-out dates IWebElement checkInOutDiv; IWebElement checkInInput; IWebElement chosenCheckInDate; IWebElement chosenCheckOutDate; //Web Elements for Number of Guests IWebElement guestsInput; IWebElement adultsStepperParent; IWebElement adultsStepper; IWebElement childrenStepperParent; IWebElement childrenStepper; //Web Elements for the search button IWebElement parentElement; IWebElement searchButton; try { //Open airbnb website System.TimeSpan maxWaitTime = new System.TimeSpan(0, 0, 120); webDriver.Manage().Timeouts().PageLoad = maxWaitTime; webDriver.Url = "https://www.airbnb.com/"; //Wait for 5 seconds for the website to load webDriver.Manage().Timeouts().ImplicitWait = System.TimeSpan.FromSeconds(5); } catch (TimeoutException e) { Assert.Fail(e.Message); } //Entering Location = Rome, Italy: try { //Get the TextBox of location and set the text to "Rome, Italy" By Locator = By.Id("bigsearch-query-detached-query"); LocationInput = webDriver.FindElement(Locator); LocationInput.SendKeys("Rome, Italy"); } catch (Exception e) { Assert.Fail("Exception Thrown when entering the location. Error Message: " + e.Message); } //Check-in and Check-out: try { checkInOutDiv = webDriver.FindElement(By.ClassName("_j8gg2a")); checkInInput = checkInOutDiv.FindElement(By.ClassName("_1akb2mdw")); checkInInput.Click(); //Get the DIV that contains the Check in and out dates and click on it to open the calender //Choose Check-in and Check-out dates chosenCheckInDate = webDriver.FindElement(By.XPath(@"/html/body/div[4]/div/div/div/div[1]/div[1]/div/header/div/div[2]/div[2]/div/div/div/form/div/div/div[3]/div[4]/section/div/div/div[1]/div/div/div/div[2]/div[2]/div/div[2]/div/table/tbody/tr[3]/td[6]")); chosenCheckOutDate = webDriver.FindElement(By.XPath(@"/html/body/div[4]/div/div/div/div[1]/div[1]/div/header/div/div[2]/div[2]/div/div/div/form/div/div/div[3]/div[4]/section/div/div/div[1]/div/div/div/div[2]/div[2]/div/div[2]/div/table/tbody/tr[4]/td[7]")); chosenCheckInDate.Click(); chosenCheckOutDate.Click(); } catch (Exception e) { Assert.Fail("Exception thrown during entering the Check-in and Check-out dates. Error Message: " + e.Message); } //Entering the number of guests: try { //Add the number of guests guestsInput = webDriver.FindElement(By.ClassName("_37ivfdq")); guestsInput.Click(); //Add two Adults adultsStepperParent = webDriver.FindElement(By.Id("stepper-adults")); adultsStepper = adultsStepperParent.FindElements(By.ClassName("_7hhhl3"))[1]; adultsStepper.Click(); adultsStepper.Click(); //Add 1 child childrenStepperParent = webDriver.FindElement(By.Id("stepper-children")); childrenStepper = childrenStepperParent.FindElements(By.ClassName("_7hhhl3"))[1]; childrenStepper.Click(); //Submit the search parentElement = webDriver.FindElement(By.ClassName("_w64aej")); searchButton = parentElement.FindElement(By.ClassName("_1mzhry13")); System.Threading.Thread.Sleep(2000); searchButton.Submit(); webDriver.Manage().Timeouts().ImplicitWait = System.TimeSpan.FromSeconds(10); } catch (System.Exception e) { Assert.Fail("Exception thown during selecting the number of guests. Error Message: " + e.Message); } }