Exemple #1
0
    public static int Main()
    {
        Base <int> fInt = new FooInt();

        Eval(fInt.Function <int>(1).Equals(1));
        Eval(fInt.Function <string>("string").Equals("string"));

        Base <object> fObject = new FooObject();

        Eval(fObject.Function <int>(1).Equals(1));
        Eval(fObject.Function <string>("string").Equals("string"));

        Base <string> fString = new FooString();

        Eval(fString.Function <int>(1).Equals(1));
        Eval(fString.Function <string>("string").Equals("string"));


        if (result)
        {
            Console.WriteLine("Test Passed");
            return(100);
        }
        else
        {
            Console.WriteLine("Test Failed");
            return(1);
        }
    }
Exemple #2
0
        public void Int32_works()
        {
            Coordinator.Configure(options => options.DataProtectionProvider = DataProtectionProvider.Create("test"));

            var myInt = 357;
            var foo   = new FooInt {
                MyInt = myInt
            };
            var json = JsonSerializer.Serialize(foo);

            // make sure it's encrypted
            using (var jsonDoc = JsonDocument.Parse(json))
            {
                var jsonProperty = jsonDoc.RootElement.GetProperty(nameof(FooInt.MyInt));
                jsonProperty.ValueKind.ShouldBe(JsonValueKind.String);
                jsonProperty.GetString().ShouldNotBe(JsonSerializer.Serialize(foo.MyInt));
            }

            // decrypt and check
            var decrypted = JsonSerializer.Deserialize <FooInt>(json);

            decrypted.MyInt.ShouldBe(myInt);
        }
        public void FillerFillsIfDifferentTypesAreIntAndBoolean()
        {
            var f1 = new FooInt
            {
                Enabled = 1,
            };

            var f2 = ObjectFiller<FooInt, FooBoolean>.Fill(f1);
            Assert.AreEqual(true, f2.Enabled);
        }
        public void FillerFillsWithDefaultValueNotNullableFromNullNullable()
        {
            var sourceObj = new FooNullableInt
                            {
                                Enabled = null,
                            };

            var destObj = new FooInt
                          {
                              Enabled = 123
                          };

            ObjectFiller<FooNullableInt, FooInt>.Fill(sourceObj, destObj);
            Assert.AreEqual(0, destObj.Enabled);
        }
        public void FillerDoesntFillDifferentTypes()
        {
            var f1 = new FooInt
            {
                Enabled = 1,
            };

            var f2 = ObjectFiller<FooInt, FooString>.Fill(f1);
            Assert.AreEqual(null, f2.Enabled);
        }