Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.DateTimeToFloorHour
DateToPointInTimeTest.cs
Source:DateToPointInTimeTest.cs
...95 [TestCase("2019-03-11 17:00:00", "2019-03-11 17:00:00")]96 [TestCase("2019-03-11 17:20:00", "2019-03-11 17:00:00")]97 [TestCase("2019-03-11 17:20:24", "2019-03-11 17:00:00")]98 [TestCase("2019-03-11 17:40:00", "2019-03-11 17:00:00")]99 public void Execute_DateTimeToFloorHour_Valid(object value, DateTime expected)100 {101 var function = new DateTimeToFloorHour();102 var result = function.Evaluate(value);103 Assert.That(result, Is.EqualTo(expected));104 }105 [Test]106 [TestCase("2019-03-11 17:00:00", "2019-03-11 17:00:00")]107 [TestCase("2019-03-11 17:20:00", "2019-03-11 18:00:00")]108 [TestCase("2019-03-11 17:20:24", "2019-03-11 18:00:00")]109 [TestCase("2019-03-11 17:40:00", "2019-03-11 18:00:00")]110 public void Execute_DateTimeToCeilingHour_Valid(object value, DateTime expected)111 {112 var function = new DateTimeToCeilingHour();113 var result = function.Evaluate(value);114 Assert.That(result, Is.EqualTo(expected));115 }...
DateTimeTransformations.cs
Source:DateTimeTransformations.cs
...115 => Default = dt;116 protected override object EvaluateNull() => Default.Execute();117 protected override object EvaluateDateTime(DateTime value) => value;118 }119 class DateTimeToFloorHour : AbstractDateTimeTransformation120 {121 protected override object EvaluateDateTime(DateTime value)122 => value.AddTicks(-1 * (value.Ticks % TimeSpan.TicksPerHour));123 }124 class DateTimeToCeilingHour : AbstractDateTimeTransformation125 {126 protected override object EvaluateDateTime(DateTime value)127 => value.AddTicks(TimeSpan.TicksPerHour - (value.Ticks % TimeSpan.TicksPerHour == 0 ? TimeSpan.TicksPerHour : value.Ticks % TimeSpan.TicksPerHour));128 }129 class DateTimeToFloorMinute : AbstractDateTimeTransformation130 {131 protected override object EvaluateDateTime(DateTime value)132 => value.AddTicks(-1 * (value.Ticks % TimeSpan.TicksPerMinute));133 }...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!