public static void MyCalculation(int[,] a, IsEqual method) { foreach (var element in a) { Console.WriteLine(MY_CALCULATION + element + " " + method(element).ToString()); } }
//public delegate bool IsEqual(int x); static public void MyCalculation(int[,] a, IsEqual func) { foreach (int i in a) { func(i); } }
public Pool(Create onCreate, Reset onReset, IsEqual equalityCheck) { this.m_Pool = new List <T>(0); this.onCreate = onCreate; this.onReset = onReset; this.equalityCheck = equalityCheck; }
public void CheckHotelPrice(IsEqual func) { if (func(DateTime.Now.DayOfWeek)) { Dlg("Сьогоднi меншi цiни!"); } }
public void No_match_if_not_equal() { var isEqual = new IsEqual<string>("test"); var matches = isEqual.Matches("somethingelse"); Assert.IsFalse(matches); }
public void No_match_if_not_equal() { var isEqual = new IsEqual <string>("test"); var matches = isEqual.Matches("somethingelse"); Assert.IsFalse(matches); }
public void No_match_if_compared_to_null() { var isEqual = new IsEqual<string>("test"); var matches = isEqual.Matches(null); Assert.IsFalse(matches); Assert.IsFalse(Is.EqualTo<string>(null).Matches("test")); }
public void No_match_if_compared_to_null() { var isEqual = new IsEqual <string>("test"); var matches = isEqual.Matches(null); Assert.IsFalse(matches); Assert.IsFalse(Is.EqualTo <string>(null).Matches("test")); }
public void MyCalculation(int[][] arr, IsEqual func) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { boolArr[i][j] = func(arr[i][j]) ? boolArr[i][j] == false : boolArr[i][j] == true; } } }
public void IsEqual_IsEqualUnitTest_HandleType_ShouldReturnIsEqual() { var decisionType = enDecisionType.IsEqual; //------------Setup for test-------------------------- var isEqual = new IsEqual(); //------------Execute Test--------------------------- //------------Assert Results------------------------- Assert.AreEqual(decisionType, isEqual.HandlesType()); }
public void UsesCustomMatchersWithGenerics() { var mock = new Mock <IEvaluateLatest>(); mock.Setup(e => e.Method(IsEqual.To(5))).Returns(1); mock.Setup(e => e.Method(IsEqual.To <int, string>(6, "foo"))).Returns(2); Assert.Equal(1, mock.Object.Method(5)); Assert.Equal(2, mock.Object.Method(6)); }
public void IsEndsWith_HandlesType_ReturnsIsEndsWithType() { var expected = enDecisionType.IsEqual; //------------Setup for test-------------------------- var isEndsWith = new IsEqual(); //------------Execute Test--------------------------- //------------Assert Results------------------------- Assert.AreEqual(expected, isEndsWith.HandlesType()); }
private static bool Operation(int[] numbers, IsEqual func) { foreach (int number in numbers) { if (func(number)) { return(true); } } return(false); }
public void TestIsEqual_DateTime_NotEqual() { Field sourceField = new LiteralField("DateTime", "sourceField", "2016-02-28"); Field targetField = new LiteralField("DateTime", "targetField", "2016-02-25"); SimpleCondition condition = new IsEqual(sourceField, targetField); bool isHold = condition.IsSimpleConditonHold(null); bool expected = false; Assert.AreEqual <bool>(expected, isHold); }
public void TestIsEqual_DecimalInt32_NotEqual() { Field sourceField = new LiteralField("Decimal", "sourceField", "2999"); Field targetField = new LiteralField("Int32", "targetField", "3000"); SimpleCondition condition = new IsEqual(sourceField, targetField); bool isHold = condition.IsSimpleConditonHold(null); bool expected = false; Assert.AreEqual <bool>(expected, isHold); }
public void Append_description() { const string test = "test"; var isEqual = IsEqual <string> .EqualTo(test); var description = new StringDescription(); isEqual.DescribeTo(description); Assert.AreEqual(description.ToString(), test); }
public SqlTag Deserialize(XmlNode node) { IsEqual equal = new IsEqual(this._configScope.DataExchangeFactory.AccessorFactory); NameValueCollection attributes = NodeUtils.ParseAttributes(node, this._configScope.Properties); equal.Prepend = NodeUtils.GetStringAttribute(attributes, "prepend"); equal.Property = NodeUtils.GetStringAttribute(attributes, "property"); equal.CompareProperty = NodeUtils.GetStringAttribute(attributes, "compareProperty"); equal.CompareValue = NodeUtils.GetStringAttribute(attributes, "compareValue"); return(equal); }
double ThisProp(IsEqual func) { foreach (var prop in props) { if (func(prop.Key)) { return(prop.Value); } } return(0); }
/// <summary> /// Deserializes the specified configuration in an <see cref="IsEqual"/> object /// </summary> /// <param name="configuration">The configuration.</param> /// <returns></returns> public override SqlTag Deserialize(IConfiguration configuration) { IsEqual isEqual = new IsEqual(accessorFactory); isEqual.Prepend = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "prepend"); isEqual.Property = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "property"); isEqual.CompareProperty = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "compareProperty"); isEqual.CompareValue = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "compareValue"); return(isEqual); }
public static void Print(int[] arr, IsEqual func) { foreach (int i in arr) { if (func(i)) { Console.Write(" " + i + " "); } } Console.WriteLine(); }
public void IsEqual_IsEqualUnitTest_Invoke_TrueIsReturned() { //init var comparer = new IsEqual(); //exe var actual = comparer.Invoke(new[] { "100", "100" }); //assert Assert.IsTrue(actual, "IsEqual returned the wrong result when comparing integers"); }
// ReSharper disable InconsistentNaming public void IsEqual_IsEqualUnitTest_Invoke_TrueIsReturned_Decimal() // ReSharper restore InconsistentNaming { //init var comparer = new IsEqual(); //exe var actual = comparer.Invoke(new[] { "1.8", "1.80" }); //assert Assert.IsTrue(actual, "IsEqual returned the wrong result when comparing integers"); }
public static int Sum(int[] arr, IsEqual func, IsEqual func2) { int sum = 0; foreach (int i in arr) { if (func(i) && func2(i)) { sum += i; } } return(sum); }
public static int Count(int[] arr, IsEqual func) { int cnt = 0; foreach (int i in arr) { if (func(i)) { cnt++; } } return(cnt); }
private static int Sum(int[] numbers, IsEqual func) { int result = 0; foreach (int i in numbers) { if (func(i)) { result += i; } } return(result); }
/// <summary> /// Deserialize a Dynamic object /// </summary> /// <param name="node"></param> /// <returns></returns> public SqlTag Deserialize(XmlNode node) { var isEqual = new IsEqual(_configScope.DataExchangeFactory.AccessorFactory); NameValueCollection prop = NodeUtils.ParseAttributes(node, _configScope.Properties); isEqual.Literal = NodeUtils.GetStringAttribute(prop, "literal"); isEqual.Prepend = NodeUtils.GetStringAttribute(prop, "prepend"); isEqual.Property = NodeUtils.GetStringAttribute(prop, "property"); isEqual.CompareProperty = NodeUtils.GetStringAttribute(prop, "compareProperty"); isEqual.CompareValue = NodeUtils.GetStringAttribute(prop, "compareValue"); return(isEqual); }
public void IsEqual_Invoke_ItemsEqual_ReturnsTrue() { //------------Setup for test-------------------------- var endsWith = new IsEqual(); string[] cols = new string[2]; cols[0] = "TestData"; cols[1] = "TestData"; //------------Execute Test--------------------------- bool result = endsWith.Invoke(cols); //------------Assert Results------------------------- Assert.IsTrue(result); }
public void IsEndsWith_Invoke_NotEqualItems_ReturnsFalse() { //------------Setup for test-------------------------- var endsWith = new IsEqual(); var cols = new string[2]; cols[0] = "TestData"; cols[1] = "No"; //------------Execute Test--------------------------- var result = endsWith.Invoke(cols); //------------Assert Results------------------------- Assert.IsFalse(result); }
private static object Operation(int[] numbers, IsEqual func) { Queue targetNumbers = new Queue(); foreach (int number in numbers) { if (func(number)) { targetNumbers.Enqueue(number); } } return(targetNumbers); }
static public void MyCalculation(int[,] arr, IsEqual func) { int m = arr.GetUpperBound(0) + 1; int n = arr.GetUpperBound(1) + 1; int max; int min; for (int i = 0; i < m; i++) { max = int.MinValue; min = int.MaxValue; bool flag_min = false; bool flag_max = false; for (int j = 0; j < n; j++) { if (arr[i, j] > max && func(arr[i, j])) { max = arr[i, j]; flag_max = true; } if (arr[i, j] < min && func(arr[i, j])) { min = arr[i, j]; flag_min = true; } } if (!flag_max) { max = 0; } if (!flag_min) { min = 0; } if (max == 0 && min == 0) { Console.WriteLine($"У рядку {i + 1} не знайдено елементи, що задовільняють умову"); } else { Console.WriteLine($"{i + 1}. min({min}) + max({max}) = {min + max}"); } } }
public void IsSatisfied_Returns_Expected_For_Given(int threshold, int actual, bool expected) { // Arrange var sut = new IsEqual { Threshold = threshold, Actual = actual }; // Act // Assert Assert.AreEqual(expected, sut.IsSatisfied()); }
public void FunctionUnderTest_ExpectedResult_UnderCondition(int threshold, int actual, bool expected) { // Arrange var sut = new IsEqual { Threshold = threshold, Actual = actual }; // Act // Assert Assert.Equal(expected, sut.IsSatisfied()); }