Best NBi code snippet using NBi.Core.Transformation.Transformer.Native.Text.EmptyToNull.TextToMask
TextTest.cs
Source:TextTest.cs  
...427        [TestCase("12345", "BE-***.***.**", "BE-123.45*.**")]428        [TestCase("(null)", "BE-***.***.**", "(null)")]429        [TestCase("(empty)", "BE-***.***.**", "BE-***.***.**")]430        [TestCase("(blank)", "BE-***.***.**", "BE-***.***.**")]431        public void Execute_TextToMask_Valid(string value, string mask, string expected)432        {433            var function = new TextToMask(new LiteralScalarResolver<string>(mask));434            var result = function.Evaluate(value);435            Assert.That(result, Is.EqualTo(expected));436        }437        [Test]438        [TestCase("12345678", "BE-***.***.**", "BE-123.456.78")]439        [TestCase("12345", "BE-***.***.**", "BE-123.45*.**")]440        [TestCase("(null)", "BE-***.***.**", "(null)")]441        [TestCase("", "BE-***.***.**", "BE-***.***.**")]442        [TestCase("(null)", "BE-***.***.**", "(empty)")]443        [TestCase("(empty)", "********", "(empty)")]444        [TestCase("(null)", "BE-***.***.**", "(blank)")]445        [TestCase("(blank)", "********", "(blank)")]446        public void Execute_MaskToText_Valid(string expected, string mask, string value)447        {...TextTransformations.cs
Source:TextTransformations.cs  
...245            else246                return base.EvaluateBlank();247        }248    }249    class TextToMask : AbstractTextTransformation250    {251        private char maskChar { get; } = '*';252        public IScalarResolver<string> Mask { get; }253        public TextToMask(IScalarResolver<string> mask)254            => Mask = mask;255        protected override object EvaluateString(string value)256        {257            var mask = Mask.Execute();258            var stringBuilder = new StringBuilder();259            var index = 0;260            foreach (var c in mask)261                if (c.Equals(maskChar))262                    stringBuilder.Append(index < value.Length ? value[index++] : maskChar);263                else264                    stringBuilder.Append(c);265            return stringBuilder.ToString();266        }267        protected override object EvaluateBlank()...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!!
