Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.DateTimeToFirstOfYear
DateToPointInTimeTest.cs
Source:DateToPointInTimeTest.cs
...240 [TestCase("2018-02-01 07:00:00", "2018-01-01")]241 [TestCase("2018-02-12 07:00:00", "2018-01-01")]242 [TestCase(null, null)]243 [TestCase("(null)", null)]244 public void Execute_DateTimeToFirstOfYear_Valid(object value, DateTime expected)245 {246 var function = new DateTimeToFirstOfYear();247 var result = function.Evaluate(value);248 if (expected == new DateTime(1, 1, 1))249 Assert.That(result, Is.Null);250 else251 Assert.That(result, Is.EqualTo(expected));252 }253 [Test]254 [TestCase("2018-02-01 00:00:00", "2018-02-28")]255 [TestCase("2018-02-01 07:00:00", "2018-02-28")]256 [TestCase("2018-02-12 07:00:00", "2018-02-28")]257 [TestCase("2020-02-12 07:00:00", "2020-02-29")]258 [TestCase(null, null)]259 [TestCase("(null)", null)]260 public void Execute_DateTimeToLastOfMonth_Valid(object value, DateTime expected)...
DateTimeTransformations.cs
Source:DateTimeTransformations.cs
...51 class DateTimeToFirstOfMonth : AbstractDateTimeTransformation52 {53 protected override object EvaluateDateTime(DateTime value) => new DateTime(value.Year, value.Month, 1);54 }55 class DateTimeToFirstOfYear : AbstractDateTimeTransformation56 {57 protected override object EvaluateDateTime(DateTime value) => new DateTime(value.Year, 1, 1);58 }59 class DateTimeToLastOfMonth : AbstractDateTimeTransformation60 {61 protected override object EvaluateDateTime(DateTime value) => new DateTime(value.Year, value.Month, 1).AddMonths(1).AddDays(-1);62 }63 class DateTimeToLastOfYear : AbstractDateTimeTransformation64 {65 protected override object EvaluateDateTime(DateTime value) => new DateTime(value.Year, 12, 31);66 }67 class DateTimeToNextDay : AbstractDateTimeTransformation68 {69 protected override object EvaluateDateTime(DateTime value) => value.AddDays(1);...
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!!