public static void RunTest() { dynamic @dynamic = new DynamicTest(); @dynamic.String = "string"; Console.WriteLine(@dynamic.String); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> testMildlyForFalseDeadlocks() internal virtual Stream <DynamicTest> TestMildlyForFalseDeadlocks() { ThrowingConsumer <Fixture> fixtureConsumer = fixture => loopRunTest(fixture, TEST_RUNS); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: return(DynamicTest.stream(Fixtures(), Fixture::toString, fixtureConsumer)); }
public void CustomDynamicObjectTest() { var custom = new DynamicTest(); custom.Dictionary["Test"] = 1; Assert.AreEqual(1, ((dynamic)custom).Test); }
/// <summary> /// 书上说dynamic速度比较快 /// 自己测试不一样 /// 估计跟C#版本有关 /// </summary> public void Test01() { int times = 1000000; Stopwatch sw = Stopwatch.StartNew(); DynamicTest t1 = new DynamicTest(); var addMethod = typeof(DynamicTest).GetMethod("Add"); var delg = (Func <DynamicTest, int, int, int>)Delegate.CreateDelegate( typeof(Func <DynamicTest, int, int, int>), addMethod); for (var i = 0; i < times; i++) { int re = delg(t1, 1, 2); } sw.Stop(); Console.WriteLine($"typeof() time:{sw.ElapsedMilliseconds}"); sw.Restart(); dynamic dy = new DynamicTest(); for (var i = 0; i < times; i++) { int re2 = dy.Add(1, 2); } sw.Stop(); Console.WriteLine($"dynamic time:{sw.ElapsedMilliseconds}"); }
public static void RunTest() { dynamic @dynamic = new DynamicTest(); @dynamic( Name: "aaaa", Count: 3 ); }
static void Main(string[] args) { dynamic foo = new DynamicTest("test"); if (foo) // treat foo as boolean { // jump in here when _xyz of foo has a value System.Console.WriteLine((string)foo); //treat foo as string //Importat: (string)foo to go operatorstring } else { // jump in here when _xyz of foo is null System.Console.WriteLine("No Value In Object"); } }
private DynamicTest RangeTest(ReadableTransactionState state, IndexOrder indexOrder, Value lo, bool includeLo, Value hi, bool includeHi, params NodeWithPropertyValues[] expected) { return(DynamicTest.dynamicTest(string.Format("range seek: lo={0} (incl: {1}), hi={2} (incl: {3})", lo, includeLo, hi, includeHi), () => { // Internal production code relies on null for unbounded, and cannot cope with NO_VALUE in this case Debug.Assert(lo != NO_VALUE); Debug.Assert(hi != NO_VALUE); AddedAndRemoved changes = indexUpdatesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder); AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeek(state, _index, IndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder); AssertContains(indexOrder, changes, changesWithValues, expected); })); }
public static void RunTest() { dynamic @dynamic = new DynamicTest() { Value = 4, Text = "Four" }; var @dynamic2 = new DynamicTest() { Value = 2, Text = "Two" }; //Note que basta con que uno este marcado con dynamic para que se realice un enlaca tardio Console.WriteLine("------------------Marcando el primero como dynamic-----------------"); var res = @dynamic + @dynamic2; Console.WriteLine($" + : {res.Value} , {res.Text}"); res = @dynamic - @dynamic2; Console.WriteLine($"- : {res.Value} , {res.Text}"); res = @dynamic * @dynamic2; Console.WriteLine($" * : {res.Value} , {res.Text}"); res = @dynamic / @dynamic2; Console.WriteLine($" / : {res.Value} , {res.Text}"); res = @dynamic & @dynamic2; Console.WriteLine($" & : {res.Value} , {res.Text}"); res = @dynamic | @dynamic2; Console.WriteLine($" | : {res.Value} , {res.Text}"); var @dynamic1 = new DynamicTest() { Value = 4, Text = "Four" }; dynamic @dynamic3 = new DynamicTest() { Value = 2, Text = "Two" }; Console.WriteLine("------------------Marcando el segundo como dynamic-----------------"); res = @dynamic1 + @dynamic3; Console.WriteLine($" + : {res.Value} , {res.Text}"); res = @dynamic1 - @dynamic3; Console.WriteLine($"- : {res.Value} , {res.Text}"); res = @dynamic1 * @dynamic3; Console.WriteLine($" * : {res.Value} , {res.Text}"); res = @dynamic1 / @dynamic3; Console.WriteLine($" / : {res.Value} , {res.Text}"); res = @dynamic1 & @dynamic3; Console.WriteLine($" & : {res.Value} , {res.Text}"); res = @dynamic1 | @dynamic3; Console.WriteLine($" | : {res.Value} , {res.Text}"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldHandleMultipleCallsToClose() internal virtual Stream <DynamicTest> ShouldHandleMultipleCallsToClose() { return(DynamicTest.stream(ArrayFactories(), NumberArrayFactoryName, factory => { // GIVEN NumberArray <object> array = factory.newIntArray(10, -1); // WHEN array.Close(); // THEN should also work array.Close(); })); }
public void ScaleNope() { var timing = Substitute.For<ICalculateTiming>(); timing.FrequencyInSeconds.Returns(new Range<int>(120, 150)); var time = Substitute.For<IDynamicTiming>(); time.Timing.Returns(timing); using (var task = new DynamicTest(time)) { Assert.IsFalse(task.Scale); } var t = time.Received().Timing; var mpins = timing.Received().FrequencyInSeconds; }
public static void RunTest() { dynamic @dynamic = new DynamicTest() { Value = 4, Text = "Four" }; //Note que basta con que uno este marcado con dynamic para que se realice un enlaca tardio Console.WriteLine("------------------Trasformacion Implicita con Reflection-----------------"); int testImplicit = @dynamic; Console.WriteLine($"dynamic == {testImplicit}"); Console.WriteLine("------------------Trasformacion Explicita sin Reflection-----------------"); string testExplicit = (string)@dynamic; Console.WriteLine($"dynamic == {testExplicit}"); }
public void Run() { var random = new Random(); var time = Substitute.For <IDynamicTiming>(); var timing = Substitute.For <ICalculateTiming>(); timing.FrequencyInSeconds.Returns(new Range <int>(1, 2)); time.Timing.Returns(timing); time.Get(false).Returns(4); using (var task = new DynamicTest(time)) { task.Run(); } time.Received().Get(false); }
public void ScaleNope() { var timing = Substitute.For <ICalculateTiming>(); timing.FrequencyInSeconds.Returns(new Range <int>(60, 300)); var time = Substitute.For <IDynamicTiming>(); time.Timing.Returns(timing); using (var task = new DynamicTest(time)) { Assert.IsFalse(task.Scale); } var t = time.Received().Timing; var mpins = timing.Received().FrequencyInSeconds; }
public void RunWorkDone() { var time = Substitute.For <IDynamicTiming>(); var timing = Substitute.For <ICalculateTiming>(); timing.FrequencyInSeconds.Returns(new Range <int>(1, 2)); time.Timing.Returns(timing); time.Get(true).Returns(99); using (var task = new DynamicTest(time)) { task.Work = true; task.Run(); } time.Received().Get(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldGetAndSetRandomItems() internal virtual Stream <DynamicTest> ShouldGetAndSetRandomItems() { ThrowingConsumer <NumberArrayTestData> throwingConsumer = data => { using (NumberArray array = data.array) { IDictionary <int, object> key = new Dictionary <int, object>(); Reader reader = data.reader; object defaultValue = reader.read(array, 0); // WHEN setting random items for (int i = 0; i < INDEXES * 2; i++) { int index = _random.Next(INDEXES); object value = data.valueGenerator.apply(_random); data.writer.write(i % 2 == 0 ? array : array.at(index), index, value); key.put(index, value); } // THEN they should be read correctly AssertAllValues(key, defaultValue, reader, array); // AND WHEN swapping some for (int i = 0; i < INDEXES / 2; i++) { int fromIndex = _random.Next(INDEXES); int toIndex; do { toIndex = _random.Next(INDEXES); } while (toIndex == fromIndex); object fromValue = reader.read(array, fromIndex); object toValue = reader.read(array, toIndex); key.put(fromIndex, toValue); key.put(toIndex, fromValue); array.swap(fromIndex, toIndex); } // THEN they should end up in the correct places AssertAllValues(key, defaultValue, reader, array); } }; return(DynamicTest.stream(Arrays().GetEnumerator(), data => data.name, throwingConsumer)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> addGet() internal virtual Stream <DynamicTest> AddGet() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.tuple.Pair<String, org.neo4j.values.storable.Value[]>> inputs = asList(testInput("NoValue", System.Func.identity(), org.neo4j.values.storable.NoValue.NO_VALUE), testInput("Boolean", org.neo4j.values.storable.Values::booleanValue, true, false, true, false), testInput("BooleanArray", org.neo4j.values.storable.Values::booleanArray, new boolean[] {false, true, false}, EMPTY_BOOLEAN_ARRAY), testInput("Byte", org.neo4j.values.storable.Values::byteValue, (byte) 0, (byte) 1, (byte) -1, Byte.MIN_VALUE, Byte.MAX_VALUE), testInput("ByteArray", org.neo4j.values.storable.Values::byteArray, new byte[] {(byte) 0, (byte) 1, (byte) -1, Byte.MIN_VALUE, Byte.MAX_VALUE}, EMPTY_BYTE_ARRAY), testInput("Short", org.neo4j.values.storable.Values::shortValue, (short) 0, (short) 1, (short) -1, Short.MIN_VALUE, Short.MAX_VALUE), testInput("ShortArray", org.neo4j.values.storable.Values::shortArray, new short[] {(short) 0, (short) 1, (short) -1, Short.MIN_VALUE, Short.MAX_VALUE}, EMPTY_SHORT_ARRAY), testInput("Char", org.neo4j.values.storable.Values::charValue, 'a', '\uFFFF', '∂', '©'), testInput("CharArray", org.neo4j.values.storable.Values::charArray, new char[] {'a', '\uFFFF', '∂', '©'}, EMPTY_CHAR_ARRAY), testInput("Int", org.neo4j.values.storable.Values::intValue, 0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE), testInput("IntArray", org.neo4j.values.storable.Values::intArray, new int[] {0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE}, EMPTY_INT_ARRAY), testInput("Long", org.neo4j.values.storable.Values::longValue, 0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE), testInput("LongArray", org.neo4j.values.storable.Values::longArray, new long[] {0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE}, EMPTY_LONG_ARRAY), testInput("Double", org.neo4j.values.storable.Values::doubleValue, 0.0, 1.0, -1.0, Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), testInput("DoubleArray", org.neo4j.values.storable.Values::doubleArray, new double[] {0.0, 1.0, -1.0, Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, EMPTY_DOUBLE_ARRAY), testInput("Float", org.neo4j.values.storable.Values::floatValue, 0.0f, 1.0f, -1.0f, Float.MIN_VALUE, Float.MAX_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY), testInput("FloatArray", org.neo4j.values.storable.Values::floatArray, new float[] {0.0f, 1.0f, -1.0f, Float.MIN_VALUE, Float.MAX_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, EMPTY_FLOAT_ARRAY), testInput("String", org.neo4j.values.storable.Values::stringValue, "", "x", "foobar"), testInput("StringArray", org.neo4j.values.storable.Values::stringArray, new String[] {"", "x", "foobar"}, EMPTY_STRING_ARRAY), testInput("Point", input -> pointValue(input.getOne(), input.getTwo()), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84, new double[] {1.0, 2.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84_3D, new double[] {1.0, 2.0, 3.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian, new double[] {1.0, 2.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian_3D, new double[] {1.0, 2.0, 3.0})), testInput("PointArray", org.neo4j.values.storable.Values::pointArray, new org.neo4j.graphdb.spatial.Point[] { pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84, 1.0, 2.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84_3D, 1.0, 2.0, 3.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian, 1.0, 2.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian_3D, 1.0, 2.0, 3.0) }, new org.neo4j.graphdb.spatial.Point[0]), testInput("Duration", org.neo4j.values.storable.Values::durationValue, (java.time.temporal.TemporalAmount) java.time.Duration.parse("P2DT3H4M"), java.time.Period.parse("P1Y2M3W4D")), testInput("DurationArray", org.neo4j.values.storable.Values::durationArray, new java.time.temporal.TemporalAmount[] {java.time.Duration.parse("P2DT3H4M"), java.time.Period.parse("P1Y2M3W4D")}, new java.time.temporal.TemporalAmount[0]), testInput("Date", org.neo4j.values.storable.DateValue::date, java.time.LocalDate.now(), java.time.LocalDate.parse("1977-05-25")), testInput("DateArray", org.neo4j.values.storable.Values::dateArray, new java.time.LocalDate[] {java.time.LocalDate.now(), java.time.LocalDate.parse("1977-05-25")}, new java.time.LocalDate[0]), testInput("Time", org.neo4j.values.storable.TimeValue::time, java.time.OffsetTime.now(), java.time.OffsetTime.parse("19:28:34.123+02:00")), testInput("TimeArray", org.neo4j.values.storable.Values::timeArray, new java.time.OffsetTime[] {java.time.OffsetTime.now(), java.time.OffsetTime.parse("19:28:34.123+02:00")}, new java.time.OffsetTime[0]), testInput("LocalTime", org.neo4j.values.storable.LocalTimeValue::localTime, java.time.LocalTime.now(), java.time.LocalTime.parse("19:28:34.123")), testInput("LocalTimeArray", org.neo4j.values.storable.Values::localTimeArray, new java.time.LocalTime[] {java.time.LocalTime.now(), java.time.LocalTime.parse("19:28:34.123")}, new java.time.LocalTime[0]), testInput("LocalDateTime", org.neo4j.values.storable.LocalDateTimeValue::localDateTime, java.time.LocalDateTime.now(), java.time.LocalDateTime.parse("1956-10-04T19:28:34.123")), testInput("LocalDateTimeArray", org.neo4j.values.storable.Values::localDateTimeArray, new java.time.LocalDateTime[] {java.time.LocalDateTime.now(), java.time.LocalDateTime.parse("1956-10-04T19:28:34.123")}, new java.time.LocalDateTime[0]), testInput("DateTime", org.neo4j.values.storable.DateTimeValue::datetime, java.time.ZonedDateTime.now(), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00")), testInput("DateTimeArray", org.neo4j.values.storable.Values::dateTimeArray, new java.time.ZonedDateTime[] { java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00") }, new java.time.ZonedDateTime[0])); IList <Pair <string, Value[]> > inputs = new IList <Pair <string, Value[]> > { TestInput("NoValue", System.Func.identity(), NoValue.NO_VALUE), TestInput("Boolean", Values.booleanValue, true, false, true, false), TestInput("BooleanArray", Values.booleanArray, new bool[] { false, true, false }, EMPTY_BOOLEAN_ARRAY), TestInput("Byte", Values.byteValue, (sbyte)0, (sbyte)1, (sbyte)-1, sbyte.MinValue, sbyte.MaxValue), TestInput("ByteArray", Values.byteArray, new sbyte[] { (sbyte)0, (sbyte)1, (sbyte)-1, sbyte.MinValue, sbyte.MaxValue }, EMPTY_BYTE_ARRAY), TestInput("Short", Values.shortValue, (short)0, (short)1, (short)-1, short.MinValue, short.MaxValue), TestInput("ShortArray", Values.shortArray, new short[] { (short)0, (short)1, (short)-1, short.MinValue, short.MaxValue }, EMPTY_SHORT_ARRAY), TestInput("Char", Values.charValue, 'a', '\uFFFF', '∂', '©'), TestInput("CharArray", Values.charArray, new char[] { 'a', '\uFFFF', '∂', '©' }, EMPTY_CHAR_ARRAY), TestInput("Int", Values.intValue, 0, 1, -1, int.MinValue, int.MaxValue), TestInput("IntArray", Values.intArray, new int[] { 0, 1, -1, int.MinValue, int.MaxValue }, EMPTY_INT_ARRAY), TestInput("Long", Values.longValue, 0L, 1L, -1L, long.MinValue, long.MaxValue), TestInput("LongArray", Values.longArray, new long[] { 0L, 1L, -1L, long.MinValue, long.MaxValue }, EMPTY_LONG_ARRAY), TestInput("Double", Values.doubleValue, 0.0, 1.0, -1.0, double.Epsilon, double.MaxValue, double.NegativeInfinity, double.PositiveInfinity), TestInput("DoubleArray", Values.doubleArray, new double[] { 0.0, 1.0, -1.0, double.Epsilon, double.MaxValue, double.NegativeInfinity, double.PositiveInfinity }, EMPTY_DOUBLE_ARRAY), TestInput("Float", Values.floatValue, 0.0f, 1.0f, -1.0f, float.Epsilon, float.MaxValue, float.NegativeInfinity, float.PositiveInfinity), TestInput("FloatArray", Values.floatArray, new float[] { 0.0f, 1.0f, -1.0f, float.Epsilon, float.MaxValue, float.NegativeInfinity, float.PositiveInfinity }, EMPTY_FLOAT_ARRAY), TestInput("String", Values.stringValue, "", "x", "foobar"), TestInput("StringArray", Values.stringArray, new string[] { "", "x", "foobar" }, EMPTY_STRING_ARRAY), TestInput("Point", input => pointValue(input.One, input.Two), Tuples.pair(CoordinateReferenceSystem.WGS84, new double[] { 1.0, 2.0 }), Tuples.pair(CoordinateReferenceSystem.WGS84_3D, new double[] { 1.0, 2.0, 3.0 }), Tuples.pair(CoordinateReferenceSystem.Cartesian, new double[] { 1.0, 2.0 }), Tuples.pair(CoordinateReferenceSystem.Cartesian_3D, new double[] { 1.0, 2.0, 3.0 })), TestInput("PointArray", Values.pointArray, new Point[] { pointValue(CoordinateReferenceSystem.WGS84, 1.0, 2.0), pointValue(CoordinateReferenceSystem.WGS84_3D, 1.0, 2.0, 3.0), pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 2.0), pointValue(CoordinateReferenceSystem.Cartesian_3D, 1.0, 2.0, 3.0) }, new Point[0]), TestInput("Duration", Values.durationValue, (TemporalAmount)Duration.parse("P2DT3H4M"), Period.parse("P1Y2M3W4D")), TestInput("DurationArray", Values.durationArray, new TemporalAmount[] { Duration.parse("P2DT3H4M"), Period.parse("P1Y2M3W4D") }, new TemporalAmount[0]), TestInput("Date", DateValue.date, LocalDate.now(), LocalDate.parse("1977-05-25")), TestInput("DateArray", Values.dateArray, new LocalDate[] { LocalDate.now(), LocalDate.parse("1977-05-25") }, new LocalDate[0]), TestInput("Time", TimeValue.time, OffsetTime.now(), OffsetTime.parse("19:28:34.123+02:00")), TestInput("TimeArray", Values.timeArray, new OffsetTime[] { OffsetTime.now(), OffsetTime.parse("19:28:34.123+02:00") }, new OffsetTime[0]), TestInput("LocalTime", LocalTimeValue.localTime, LocalTime.now(), LocalTime.parse("19:28:34.123")), TestInput("LocalTimeArray", Values.localTimeArray, new LocalTime[] { LocalTime.now(), LocalTime.parse("19:28:34.123") }, new LocalTime[0]), TestInput("LocalDateTime", LocalDateTimeValue.localDateTime, DateTime.Now, DateTime.Parse("1956-10-04T19:28:34.123")), TestInput("LocalDateTimeArray", Values.localDateTimeArray, new DateTime[] { DateTime.Now, DateTime.Parse("1956-10-04T19:28:34.123") }, new DateTime[0]), TestInput("DateTime", DateTimeValue.datetime, ZonedDateTime.now(), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00")), TestInput("DateTimeArray", Values.dateTimeArray, new ZonedDateTime[] { ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00") }, new ZonedDateTime[0]) }; return(DynamicTest.stream(inputs.GetEnumerator(), Pair.getOne, pair => { Value[] values = pair.Two; long[] refs = values.Select(_container.add).ToArray(); for (int i = 0; i < values.Length; i++) { assertEquals(values[i], _container.get(refs[i])); } })); }
public static void RunTest() { dynamic @dynamic = new DynamicTest(); @dynamic[1, 3, 4, 5, 6, 7] = 3; foreach (object item in @dynamic[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) { if (item == null) { Console.Write("null, "); } else { Console.Write(item + ", "); } } Console.WriteLine(); //@dynamic[1:2]; }
public void RunStepUp() { var random = new Random(); var min = random.Next(1, 30); var max = random.Next(90, 1024); var time = Substitute.For <IDynamicTiming>(); var timing = Substitute.For <ICalculateTiming>(); timing.FrequencyInSeconds.Returns(new Range <int>(1, 2)); time.Timing.Returns(timing); time.Get(true).Returns(99); using (var task = new DynamicTest(time)) { task.Work = true; task.Run(); task.Run(); task.Run(); } time.Received(3).Get(true); }
public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result) { result = new DynamicTest(); ConstantExpression left = Expression.Constant(this.Value); ConstantExpression right = Expression.Constant(((DynamicTest)arg).Value); BinaryExpression exp = Expression.MakeBinary(binder.Operation, left, right); Expression <Func <int> > lam = Expression.Lambda <Func <int> >(exp); Func <int> fun = lam.Compile(); ((DynamicTest)result).Value = fun(); //forma inicial e intuitiva de implementar este metodo //ademas no encontre rapido como trabajar el arbol para string de forma generica switch (binder.Operation) { case ExpressionType.Add: ((DynamicTest)result).Text = this.Text + "+" + ((DynamicTest)arg).Text; break; case ExpressionType.Subtract: ((DynamicTest)result).Text = this.Text + "-" + ((DynamicTest)arg).Text; break; case ExpressionType.Multiply: ((DynamicTest)result).Text = this.Text + "*" + ((DynamicTest)arg).Text; break; case ExpressionType.Divide: ((DynamicTest)result).Text = this.Text + "/" + ((DynamicTest)arg).Text; break; default: ((DynamicTest)result).Text = "operation isn't defined for string"; break; } return(true); }
public void RunStepUp() { var random = new Random(); var min = random.Next(1, 30); var max = random.Next(90, 1024); var time = Substitute.For<IDynamicTiming>(); time.Get(true).Returns(99); using (var task = new DynamicTest(time)) { task.Work = true; task.Run(); task.Run(); task.Run(); } time.Received(3).Get(true); }
public void RunStepDown() { var random = new Random(); var time = Substitute.For<IDynamicTiming>(); time.Get(false).Returns(99); time.Get(false).Returns(99); time.Get(false).Returns(99); using (var task = new DynamicTest(time)) { task.Run(); task.Run(); task.Run(); } time.Get(false).Returns(99); time.Get(false).Returns(99); time.Get(false).Returns(99); }
static void Main(string[] args) { var dt = new DynamicTest(0); var array = new int[] { 42 }; Action <int> action = x => { }; dynamic d = 0; // DynamicObjectCreation new DynamicTest(d); new DynamicTest(d) { Field = d }; new KeyValuePair <string, dynamic>("", d); new System.Collections.Generic.KeyValuePair <string, dynamic>("", d); // ObjectCreation new DynamicTest(0); new DynamicTest(0) { Field = d }; // DynamicMethodCall d.Bar(""); Foo(d); // MethodCall dt.Bar(""); Foo(0); // DynamicOperatorCall d = 0; d = -d; d = d + d; d += d; // OperatorCall var i = 0; i = -i; i = i + i; i += i; i++; // DynamicMutatorOperatorCall d++; // MutatorOperatorCall i++; // DynamicMemberAccess d.Field = 0; d.Prop = d.Prop; // MemberAccess dt.Field = 0; dt.Prop = dt.Prop; // DynamicElementAccess d = array; d[0] = d[0]; d = d?[0]; // ElementAccess d = 0; dt[0] = dt[d]; d = dt?[0]; array[0] = array[d]; d = array?[0]; // DelegateCall action(3); d = action; d(42); }