public void TestRequiredFieldHappyPathForInheritedClass()
        {
            RequiredFieldBase inheritedObject = new RequiredFieldDerived()
            {
                BaseStringType     = "Payments",
                DerivedIntegerType = 10
            };

            Assert.IsTrue(SwagValidator.Validate(inheritedObject));
        }
        public void TestTryValidateRequiredFieldHappyPathForInheritedClass()
        {
            var msg = "";
            RequiredFieldBase inheritedObject = new RequiredFieldDerived()
            {
                BaseStringType     = "Payments",
                DerivedIntegerType = 10
            };

            var res = SwagValidator.TryValidate(inheritedObject, out msg);

            Assert.IsTrue(res);
            Assert.IsNull(msg);
        }
        public void TestTryValidateRequiredFieldNoOutputJson()
        {
            var derivedObject = new RequiredFieldDerived()
            {
                BaseStringType = "Payments"
            };

            var msg = string.Empty;

            var status = SwagValidator.TryValidate(derivedObject, out msg, false);

            Assert.IsFalse(status);
            Assert.AreEqual(msg, "Value cannot be null or zero. Parameter name: DerivedIntegerType");
        }
        public void SenseitiveDataTest()
        {
            var obj = new RequiredFieldDerived()
            {
                BaseIntegerType    = 5,
                BaseStringType     = "asdasd",
                DerivedIntegerType = 33,
                DerivedStringType  = "xxxx",
                SensitiveInt       = 1111,
                SensitiveString    = "yyyy"
            };

            var res = obj.ObjToJson();

            Assert.IsFalse(res.Contains("yyyy"));
            Assert.IsFalse(res.Contains("1111"));
        }
        public void TestSensitiveFields()
        {
            var derivedObject = new RequiredFieldDerived()
            {
                BaseStringType  = "Payments",
                SensitiveString = "this should be null",
                SensitiveInt    = 88888
            };

            var msg = string.Empty;

            var status = SwagValidator.TryValidate(derivedObject, out msg);

            Assert.IsFalse(status);

            Assert.IsFalse(msg.Contains("this should be null"));
            Assert.IsFalse(msg.Contains("88888"));
        }
        public void TestRequiredFieldForDerivedClassProperties()
        {
            RequiredFieldDerived derivedObject = new RequiredFieldDerived()
            {
                BaseStringType = "Payments"
            };

            try
            {
                SwagValidator.Validate(derivedObject);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, "Value cannot be null or zero. Parameter name: DerivedIntegerType");
                return;
            }

            Assert.IsTrue(false);
        }