Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.DateTimeToDate
DateToPointInTimeTest.cs
Source:DateToPointInTimeTest.cs
...202 Assert.That(result, Is.EqualTo(expected));203 }204 [Test]205 [TestCase("2018-02-01 07:00:00")]206 public void Execute_DateTimeToDate_Valid(object value)207 {208 var function = new DateTimeToDate();209 var result = function.Evaluate(value);210 Assert.That(result, Is.EqualTo(new DateTime(2018, 2, 1)));211 }212 [Test]213 [TestCase("2018-02-01 07:00:00", "2018-02-01 07:00:00")]214 [TestCase(null, "2001-01-01")]215 [TestCase("", "2001-01-01")]216 [TestCase("(null)", "2001-01-01")]217 public void Execute_NullToDate_Valid(object value, DateTime expected)218 {219 var function = new NullToDate(new LiteralScalarResolver<DateTime>(new DateTime(2001, 1, 1)));220 var result = function.Evaluate(value);221 Assert.That(result, Is.EqualTo(expected));222 }...
NativeTransformationFactoryTest.cs
Source:NativeTransformationFactoryTest.cs
...21 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;22 var result = factory.Instantiate("dateTime-to-date");23 24 Assert.That(result, Is.AssignableTo<INativeTransformation>());25 Assert.That(result, Is.TypeOf<DateTimeToDate>());26 }27 [Test]28 public void Instantiate_ExistingWithoutParameterAndWhitespaces_CorrectType()29 {30 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;31 var result = factory.Instantiate("\t\tdateTime-to-date\r\n");32 Assert.That(result, Is.AssignableTo<INativeTransformation>());33 Assert.That(result, Is.TypeOf<DateTimeToDate>());34 }35 [Test]36 public void Instantiate_ExistingWithParameter2_CorrectType()37 {38 var factory = new NativeTransformationFactory(new ServiceLocator(), null);;39 var result = factory.Instantiate("text-to-pad-right(6, *)");40 Assert.That(result, Is.AssignableTo<INativeTransformation>());41 Assert.That(result, Is.TypeOf<TextToPadRight>());42 Assert.That((result as TextToPadRight).Length.Execute(), Is.EqualTo(6));43 Assert.That((result as TextToPadRight).Character.Execute(), Is.EqualTo('*'));44 }45 [Test]46 public void Instantiate_ExistingWithParameter_CorrectType()47 {...
DateTimeTransformations.cs
Source:DateTimeTransformations.cs
...30 }31 protected virtual object EvaluateNull() => null;32 protected abstract object EvaluateDateTime(DateTime value);33 }34 class DateTimeToDate : AbstractDateTimeTransformation35 {36 protected override object EvaluateDateTime(DateTime value) => value.Date;37 }38 class DateToAge : AbstractDateTimeTransformation39 {40 protected override object EvaluateNull() => 0;41 protected override object EvaluateDateTime(DateTime value)42 {43 // Save today's date.44 var today = DateTime.Today;45 // Calculate the age.46 var age = today.Year - value.Year;47 // Go back to the year the person was born in case of a leap year48 return value.AddYears(age) > today ? age-- : age;...
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!!