Example #1
0
        public void SimpleTest()
        {
            var obj = new RangeTestObj
            {
                dec = predefinedValue,
                dub = predefinedValue,
                ing = predefinedValue,
                lng = predefinedValue
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(obj, Constants.ScrubMode.Marked);

            processor.Scrub();
            var cleanedData = (RangeTestObj)processor.CleanData();

            var man = processor.GetManifest();

            Assert.InRange(cleanedData.dub, 100, 200);
            Assert.InRange(cleanedData.dec, 100, 200);
            Assert.InRange(cleanedData.ing, 100, 200);
            Assert.InRange(cleanedData.lng, 100, 200);
            Assert.NotNull(cleanedData);
            Assert.IsType <RangeTestObj>(cleanedData);
            Assert.True(processor.CheckManifest());
        }
Example #2
0
        public void FileScrub_EnsureFileIsScrubbed()
        {
            const string fileStr          = "This is a string to fake a file";
            const string expectedFileText = "Hello World";

            var model = new FileTest {
                str         = "strings",
                emailString = "*****@*****.**",
                orderFile   = Encoding.ASCII.GetBytes(fileStr)
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Full);

            processor.Scrub();

            var cleanData = (FileTest)processor.CleanData();

            var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".txt");

            File.WriteAllBytes(path, cleanData.orderFile);

            var fileText = File.ReadAllText(path).Where(c => !char.IsControl(c)).ToArray();

            Assert.NotNull(cleanData.orderFile);
            Assert.Equal(expectedFileText, fileText);
        }
Example #3
0
        public void ArrayScrub_EnsureSameTypeArrayReturnedScrubbed()
        {
            var testIntArray = new int[] { 50, 10, 25, 30 };
            var testStrArray = new string[] { "string", "strings", "stringys", "stringy strings" };

            var model = new ArrayTest
            {
                arrayInt = testIntArray,
                arrayStr = testStrArray,
                str      = "Test string"
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Full);

            processor.Scrub();
            var cleanedData = (ArrayTest)processor.CleanData();

            Assert.NotEqual(testIntArray[1], cleanedData.arrayInt[1]);
            Assert.NotEqual(testStrArray[1], cleanedData.arrayStr[1]);
            Assert.Equal(testIntArray.Length, cleanedData.arrayInt.Length);
            Assert.Equal(testStrArray.Length, cleanedData.arrayStr.Length);
            Assert.NotNull(cleanedData);
            Assert.IsType <ArrayTest>(cleanedData);
            Assert.True(processor.CheckManifest());
        }
Example #4
0
        public void GivenString_ScrubToNumber_SaveState()
        {
            const string Id    = "String";
            const string IdTwo = "Another String";

            var model = new StatefulStringIdTest
            {
                Id    = Id,
                IdTwo = IdTwo
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Marked);

            processor.Scrub();
            var cleanedData = (StatefulStringIdTest)processor.CleanData();

            var man = processor.GetManifest();

            //StateOne Asserts
            Assert.Equal(cleanedData.Id, cleanedData.IdTwo);
            Assert.NotEqual(cleanedData.Id, Id);
            Assert.NotEqual(cleanedData.IdTwo, IdTwo);

            Assert.NotNull(cleanedData);
            Assert.IsType <StatefulStringIdTest>(cleanedData);
            Assert.True(processor.CheckManifest());
        }
Example #5
0
        public void TestStatefulAttribute(string randomStr, string otherStatful)
        {
            var model = new StatefulTest
            {
                i = 5,
                statefulString    = randomStr,
                str               = "strings",
                InnerStatefulTest = new InnerStatefulTest
                {
                    anotherStateful = otherStatful,
                    j = 50
                }
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Marked);

            processor.Scrub();
            var cleanedData = (StatefulTest)processor.CleanData();

            var man = processor.GetManifest();

            Assert.NotEqual(randomStr, cleanedData.statefulString);
            Assert.NotEqual(otherStatful, cleanedData.InnerStatefulTest.anotherStateful);
            Assert.Equal(cleanedData.statefulString, cleanedData.InnerStatefulTest.anotherStateful);
            Assert.NotNull(cleanedData);
            Assert.IsType <StatefulTest>(cleanedData);
            Assert.True(processor.CheckManifest());
        }
Example #6
0
        public void MarkedScrubModeTest()
        {
            const string email       = "this really isn't an email right?";
            const string stayTheSame = "This should be..";
            var          model       = new SimpleTest
            {
                emailStr      = email,
                KeepMeTheSame = stayTheSame
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Marked);

            processor.Scrub();

            var cleanData    = (SimpleTest)processor.CleanData();
            var man          = processor.GetManifest();
            var IsSuccessful = processor.CheckManifest();

            Assert.IsType <SimpleTest>(cleanData);
            Assert.True(IsSuccessful);
            Assert.Equal(stayTheSame, cleanData.KeepMeTheSame);
            Assert.NotEqual(email, cleanData.emailStr);
        }
Example #7
0
        public void ScrubProperty_WithPredefinedValue()
        {
            const int    _i   = 10;
            const string _str = "ACB";

            var model = new PreserveTest
            {
                str = "Fake string",
                i   = 50
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(model, Constants.ScrubMode.Full);

            processor.Scrub();
            var cleanedData = (PreserveTest)processor.CleanData();

            var man = processor.GetManifest();

            Assert.Equal(_i, cleanedData.i);
            Assert.Equal(_str, cleanedData.str);
            Assert.NotNull(cleanedData);
            Assert.IsType <PreserveTest>(cleanedData);
            Assert.True(processor.CheckManifest());
        }
Example #8
0
        public void SimpleTest(string email)
        {
            string[] str = { "test", "testing", "test" };

            SimpleTest test = new SimpleTest
            {
                emailStr = email,
                str      = "test string",
                strTwo   = str,
                Byte     = Encoding.ASCII.GetBytes("Test STring")
            };

            IShamWow processor = ShamWowEngine.GetFactory().Create(test, Constants.ScrubMode.Marked);

            processor.Scrub();
            var cleanedData = (SimpleTest)processor.CleanData();

            var man = processor.GetManifest();

            Assert.NotEqual(cleanedData.emailStr, email);
            Assert.NotNull(cleanedData);
            Assert.IsType <SimpleTest>(cleanedData);
            Assert.True(processor.CheckManifest());
        }