public void TestCheckValuesInputInt(int input, int min, int max, bool expected) { var check = new CheckValues(); var actual = check.IsValidInt(input, min, max); Assert.Equal(expected, actual); }
public void TestCheckValuesInputDouble(double input, double min, double max, bool expected) { var check = new CheckValues(); var actual = check.IsValidDouble(input, min, max); Assert.Equal(expected, actual); }
/// <summary> /// 選択用リストの初期化 /// </summary> void setCheckList() { CheckValues.Add(new KeyValuePair <string, string>("第1項目", "1")); CheckValues.Add(new KeyValuePair <string, string>("第2項目", "2")); CheckValues.Add(new KeyValuePair <string, string>("第3項目", "3")); CheckValues.Add(new KeyValuePair <string, string>("第4項目", "4")); CheckValues.Add(new KeyValuePair <string, string>("最終項目", "5")); }
public void CheckCharCorrectness_WhenCharCorrect_ReturnTrue(string ch, int pos, bool expected) { CheckValues p = new CheckValues(); bool validate = p.CheckCharCorrectness(ch, pos); validate.Should().Be(expected); }
public void CheckNumberCorrectness_WhenNumberCorrect_ReturnTrue(string num, bool expected) { CheckValues p = new CheckValues(); bool validate = p.CheckNumberCorrectness(num); validate.Should().Be(expected); }
public void CheckValueCorrectness_WhenValuesCorrect_ReturnTrue(string[] arr, bool expected) { CheckValues p = new CheckValues(); bool validate = p.CheckValuesCorrectness(arr); validate.Should().Be(expected); }
public void CheckValueCorrectness_InvalidArrayLength_Exception(string[] arr, bool expected) { CheckValues p = new CheckValues(); Action act = () => p.CheckValuesCorrectness(arr); act.Should().Throw <ArgumentException>(); }
/// <summary> /// 選択用リストの初期化 /// </summary> void setCheckList() { CheckValues.Add("1", "第1項目"); CheckValues.Add("2", "第2項目"); CheckValues.Add("3", "第3項目"); CheckValues.Add("4", "第4項目"); CheckValues.Add("5", "第5項目"); }
public static void CheckMapItem(string Index, CheckFunction checkFn, DecodedContainer arrayContainer, CheckValues checkValues) { Assert.IsTrue(arrayContainer.solidityVar.name == checkValues.parentName, "Error the parent name does not match it should be " + arrayContainer.solidityVar.name); DecodedContainer current = arrayContainer; current = current.children.Find(a => a.key == Index); Assert.IsTrue(current != null, "Error map check failed index is {0} but count is {1}", Index, current.children.Count); Assert.IsTrue(checkFn(current, checkValues), "Check function failed for " + arrayContainer.solidityVar.name); }
public static void CheckArrayItem(int index, CheckFunction checkFn, DecodedContainer arrayContainer, CheckValues checkValues) { if (arrayContainer.children.Count > index) { Assert.IsTrue(checkFn(arrayContainer.children[index], checkValues), string.Format("Error check array failed on check function for array {0} length {1}", arrayContainer.solidityVar.name, arrayContainer.children.Count)); } else { Assert.Fail("Error array check failed index is {0} but count is {1}", index, arrayContainer.children.Count); } }
public static bool StructCheckFunction(DecodedContainer parentContainer, CheckValues structValues) { if (parentContainer.children.Count > structValues.checkIndex) { for (int i = 0; i < structValues.nameValues.Count; i++) { if (!(parentContainer.children[i].solidityVar.name == structValues.nameValues[i].Name && parentContainer.children[i].decodedValue == structValues.nameValues[i].Value)) { return(false); } } return(true); } return(false); }
public static void TestMethod1() { MemoryPoolTest.TestMemoryLeak(); int blockSize = 128; IndexMapper map = new IndexMapper(blockSize); CheckValues check = new CheckValues(blockSize); uint lastAddress = (uint)Math.Min(uint.MaxValue, (long)check.BlocksPerPage * (long)check.BlocksPerPage * (long)check.BlocksPerPage * (long)check.BlocksPerPage - 1); //this line is to shortcut so the test is less comprehensive. for (uint x = 0; x <= lastAddress; x++) { map.MapPosition(x); check.Check(map, x); } MemoryPoolTest.TestMemoryLeak(); }
public static string CheckBoxList(this HtmlHelper htmlHelper, string name, CheckValues values, IDictionary<string, object> htmlAttributes) { if (values == null) throw new ArgumentException("Value cannot be null.", "values"); var sb = new StringBuilder(); for (int i = 0; i < values.Count; i++) { sb.Append(htmlHelper.Hidden(name + "[" + i + "].Key", values.Keys[i])); sb.Append("<label>"); sb.Append(htmlHelper.CheckBox(name + "[" + i + "].Value", values.Values[i], htmlAttributes)); sb.Append(values.Keys[i]); sb.Append("</label>"); } return sb.ToString(); }
private void Button_Click2(object sender, RoutedEventArgs e) { MainWindowViewModel mbwallet = (root.DataContext as MainWindowViewModel); Script lScript = mbwallet.SelectedWallet.CurrentAddress.ScriptPubKey; KeyPath lKeyPath = ViewModel.SelectedWallet.Wallet.GetKeyPath(lScript); ExtKey lPrivKey = mbwallet.SelectedWallet.PrivateKeys[0].ExtKey.Derive(lKeyPath); BitcoinAddress lMyAddress = mbwallet.SelectedWallet.CurrentAddress; if (CheckValues.CheckIfNull(this)) { return; } if (!decimal.TryParse(Value.Text, out decimal lMoney)) { MessageBox.Show("This can only be numbers", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } List <ICoin> coins = GetCoins(lMoney); decimal total = coins.Sum(x => Convert.ToDecimal(x.Amount.ToString())); if (total < Convert.ToDecimal(lMoney)) { MessageBox.Show("Does not have enough funds\nFunds: " + total + "\nValue to Send: " + lMoney, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } BitcoinAddress lDestination = BitcoinAddress.Create(Address.Text, App.Network); TransactionBuilder txBuilder = new TransactionBuilder(); Transaction lTx = txBuilder .AddCoins(coins) .AddKeys(lPrivKey) .Send(lDestination, new Money(lMoney, MoneyUnit.BTC)) .SendFees("0.0001") .SetChange(lMyAddress) .BuildTransaction(true); broad(lTx); List <ICoin> GetCoins(decimal sendAmount) { var txInAmount = Money.Zero; var coins1 = new List <ICoin>(); foreach (var balance in client.GetBalance(lMyAddress, true).Result.Operations) { var transactionId = balance.TransactionId; var transactionResponse = client.GetTransaction(transactionId).Result; var receivedCoins = transactionResponse.ReceivedCoins; foreach (Coin coin in receivedCoins) { if (coin.TxOut.ScriptPubKey == lMyAddress.ScriptPubKey) { coins1.Add(coin); txInAmount += (coin.Amount as Money); } } } return(coins1); } }
public static string CheckBoxList(this HtmlHelper htmlHelper, string name, CheckValues values) { return htmlHelper.CheckBoxList(name, values, new RouteValueDictionary()); }
public static bool CheckValueFunction(DecodedContainer parentContainer, CheckValues checkValues) { return(parentContainer.solidityVar.name == checkValues.parentName && parentContainer.decodedValue == checkValues.value); }