コード例 #1
0
    public static void ApplyFooDefaults(this Foo3 foo3)
    {
        foo3.Name    = "Foo 3";
        foo3.MaxSize = Int32.MaxValue;

        Console.WriteLine(foo3);
    }
コード例 #2
0
        public void CanSerializeType()
        {
            var serializer = new JsonSerializer<Foo3>();

            var foo = new Foo3 { Bar = typeof(Foo3) };

            var json = serializer.Serialize(foo);

            Assert.That(json, Is.EqualTo(@"{""Bar"":""XSerializer.Tests.JsonMiscellaneousTypesTests+Foo3, XSerializer.Tests""}"));
        }
コード例 #3
0
 private static MyInterface[] MakeInterfaceArray()
 {
     MyInterface[] itfs = new MyInterface[50];
     itfs[0]  = new Foo0();
     itfs[1]  = new Foo1();
     itfs[2]  = new Foo2();
     itfs[3]  = new Foo3();
     itfs[4]  = new Foo4();
     itfs[5]  = new Foo5();
     itfs[6]  = new Foo6();
     itfs[7]  = new Foo7();
     itfs[8]  = new Foo8();
     itfs[9]  = new Foo9();
     itfs[10] = new Foo10();
     itfs[11] = new Foo11();
     itfs[12] = new Foo12();
     itfs[13] = new Foo13();
     itfs[14] = new Foo14();
     itfs[15] = new Foo15();
     itfs[16] = new Foo16();
     itfs[17] = new Foo17();
     itfs[18] = new Foo18();
     itfs[19] = new Foo19();
     itfs[20] = new Foo20();
     itfs[21] = new Foo21();
     itfs[22] = new Foo22();
     itfs[23] = new Foo23();
     itfs[24] = new Foo24();
     itfs[25] = new Foo25();
     itfs[26] = new Foo26();
     itfs[27] = new Foo27();
     itfs[28] = new Foo28();
     itfs[29] = new Foo29();
     itfs[30] = new Foo30();
     itfs[31] = new Foo31();
     itfs[32] = new Foo32();
     itfs[33] = new Foo33();
     itfs[34] = new Foo34();
     itfs[35] = new Foo35();
     itfs[36] = new Foo36();
     itfs[37] = new Foo37();
     itfs[38] = new Foo38();
     itfs[39] = new Foo39();
     itfs[40] = new Foo40();
     itfs[41] = new Foo41();
     itfs[42] = new Foo42();
     itfs[43] = new Foo43();
     itfs[44] = new Foo44();
     itfs[45] = new Foo45();
     itfs[46] = new Foo46();
     itfs[47] = new Foo47();
     itfs[48] = new Foo48();
     itfs[49] = new Foo49();
     return(itfs);
 }
コード例 #4
0
    public void MapsTo()
    {
        var foo = new Foo3
        {
            Bar = TimeSpan.FromHours(10)
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(Offset.FromTimeSpan(foo.Bar));
    }
コード例 #5
0
    public void MapsTo_DateTime()
    {
        var foo = new Foo3
        {
            Bar = DateTime.UtcNow
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(Instant.FromDateTimeUtc(foo.Bar));
    }
コード例 #6
0
    public void MapsTo_TimeSpan()
    {
        var foo = new Foo3
        {
            Bar = TimeSpan.FromDays(1)
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(Duration.FromTimeSpan(foo.Bar));
    }
コード例 #7
0
    public void MapsTo()
    {
        var foo = new Foo3
        {
            Bar = DateTime.Now
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(LocalDateTime.FromDateTime(foo.Bar));
    }
コード例 #8
0
    public void MapsTo()
    {
        var foo = new Foo3
        {
            Bar = "P5M"
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(PeriodPattern.Roundtrip.Parse(foo.Bar).Value);
    }
コード例 #9
0
    public void MapsTo_DateTime()
    {
        var foo = new Foo3
        {
            Bar = TimeSpan.FromMinutes(502)
        };

        var result = Mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(new LocalTime(502 / 60, 502 % 60));
    }
コード例 #10
0
        public void CanSerializeType()
        {
            var serializer = new JsonSerializer <Foo3>();

            var foo = new Foo3 {
                Bar = typeof(Foo3)
            };

            var json = serializer.Serialize(foo);

            Assert.That(json, Is.EqualTo(@"{""Bar"":""XSerializer.Tests.JsonMiscellaneousTypesTests+Foo3, XSerializer.Tests""}"));
        }
コード例 #11
0
        public void FillerWithLessPropertiesTest()
        {
            var f1 = new Foo
            {
                Name = "Silvio",
                Id = 1
            };

            var f2 = new Foo3();
            ObjectFiller<Foo, Foo3>.Fill(f1, f2);
            Assert.AreEqual(f1.Name, f2.Name);
        }
コード例 #12
0
    public void MapsTo()
    {
        var mapper = Config.CreateMapper();

        var foo = new Foo3
        {
            Bar = "P5M"
        };

        var result = mapper.Map <Foo1>(foo).Bar;

        result !.Should().Be(PeriodPattern.Roundtrip.Parse(foo.Bar).Value);
    }
コード例 #13
0
    public void MapsTo()
    {
        var mapper = Config.CreateMapper();

        var foo = new Foo3
        {
            Bar = DateTimeOffset.Now
        };

        var result = mapper.Map <Foo1>(foo).Bar;

        result.Should().Be(OffsetDateTime.FromDateTimeOffset(foo.Bar));
    }
コード例 #14
0
    public static int Main()
    {
        bool ok = true;
        int  result;

        Foo3 x3 = new Foo3();
        Foo2 x2 = new Foo3();
        Foo1 x1 = new Foo3();
        IFoo x  = new Foo3();

        Bar3 <int> y3 = new Bar3 <int>();
        Bar2 <int> y2 = new Bar3 <int>();
        Bar1 <int> y1 = new Bar3 <int>();
        IBar <int> y  = new Bar3 <int>();

        if ((result = x3.A()) != 2)
        {
            Console.WriteLine("NOT OK: calling Foo3.A() did not return 2! it returned " + result); ok = false;
        }
        if ((result = x2.A()) != 2)
        {
            Console.WriteLine("NOT OK: calling Foo2.A() did not return 2! it returned " + result); ok = false;
        }
        if ((result = x1.A()) != 1)
        {
            Console.WriteLine("NOT OK: calling Foo1.A() did not return 1! it returned " + result); ok = false;
        }
        if ((result = x.A()) != 2)
        {
            Console.WriteLine("NOT OK: calling IFoo.A() did not return 2! it returned " + result); ok = false;
        }

        if ((result = y3.A <string>()) != 2)
        {
            Console.WriteLine("NOT OK: calling Bar3.A() did not return 2! it returned " + result); ok = false;
        }
        if ((result = y2.A <string>()) != 2)
        {
            Console.WriteLine("NOT OK: calling Bar2.A() did not return 2! it returned " + result); ok = false;
        }
        if ((result = y1.A <string>()) != 1)
        {
            Console.WriteLine("NOT OK: calling Bar1.A() did not return 1! it returned " + result); ok = false;
        }
        if ((result = y.A <string>()) != 2)
        {
            Console.WriteLine("NOT OK: calling IBar.A() did not return 2! it returned " + result); ok = false;
        }

        return((ok) ? (100) : (-1));
    }
コード例 #15
0
ファイル: TypedSetTests.cs プロジェクト: unimator/Desolation
        public void ShouldReturnItemOfDesiredTypeIfContains()
        {
            //arrange
            var set         = new TypedSet <FooBase>();
            var desiredItem = new Foo3();

            set.Insert(new Foo1());
            set.Insert(new Foo2());
            set.Insert(desiredItem);

            //act
            var returnedItem = set.Get <Foo3>();

            //assert
            Assert.AreEqual(desiredItem, returnedItem);
        }
コード例 #16
0
        public void CanRoundTripReadOnlyPropertiesWhoseTypesCanBeAssignedToConstructorParameters()
        {
            var foo = new Foo3(
                GetReadOnlyCollection(),
                GetReadOnlyCollection(),
                GetReadOnlyDictionary(),
                GetReadOnlyDictionary(),
                GetReadOnlyCollection());

            var serializer = new XmlSerializer <Foo3>(x => x.Indent());

            var xml = serializer.Serialize(foo);

            var roundTrip = serializer.Deserialize(xml);

            Assert.That(roundTrip, Has.PropertiesEqualTo(foo));
        }
コード例 #17
0
ファイル: TypedSetTests.cs プロジェクト: unimator/Desolation
        public void ShouldDoNothingIfItemOfDesiredTypeDoesNotExistInSet()
        {
            //arrange
            var set          = new TypedSet <FooBase>();
            var itemToRemove = new Foo3();

            set.Insert(new Foo1());
            set.Insert(new Foo2());

            //act
            set.Remove(itemToRemove);
            var containsResult = set.Contains <Foo2>();

            //assert
            Assert.AreEqual(true, containsResult);
            Assert.AreEqual(2, set.Count());
        }
コード例 #18
0
        public void CanRoundTripReadOnlyPropertiesWhoseTypesCanBeAssignedToConstructorParameters()
        {
            var foo = new Foo3(
                GetReadOnlyCollection(),
                GetReadOnlyCollection(),
                GetReadOnlyDictionary(),
                GetReadOnlyDictionary(),
                GetReadOnlyCollection());

            var serializer = new XmlSerializer<Foo3>(x => x.Indent());

            var xml = serializer.Serialize(foo);

            var roundTrip = serializer.Deserialize(xml);

            Assert.That(roundTrip, Has.PropertiesEqualTo(foo));
        }
コード例 #19
0
 public void Foo3(Foo3 input)
 {
 }
コード例 #20
0
ファイル: Interfaces.cs プロジェクト: faizur/corert
    private static int TestInterfaceCache()
    {
        MyInterface[] itfs = new MyInterface[50];

        itfs[0]  = new Foo0();
        itfs[1]  = new Foo1();
        itfs[2]  = new Foo2();
        itfs[3]  = new Foo3();
        itfs[4]  = new Foo4();
        itfs[5]  = new Foo5();
        itfs[6]  = new Foo6();
        itfs[7]  = new Foo7();
        itfs[8]  = new Foo8();
        itfs[9]  = new Foo9();
        itfs[10] = new Foo10();
        itfs[11] = new Foo11();
        itfs[12] = new Foo12();
        itfs[13] = new Foo13();
        itfs[14] = new Foo14();
        itfs[15] = new Foo15();
        itfs[16] = new Foo16();
        itfs[17] = new Foo17();
        itfs[18] = new Foo18();
        itfs[19] = new Foo19();
        itfs[20] = new Foo20();
        itfs[21] = new Foo21();
        itfs[22] = new Foo22();
        itfs[23] = new Foo23();
        itfs[24] = new Foo24();
        itfs[25] = new Foo25();
        itfs[26] = new Foo26();
        itfs[27] = new Foo27();
        itfs[28] = new Foo28();
        itfs[29] = new Foo29();
        itfs[30] = new Foo30();
        itfs[31] = new Foo31();
        itfs[32] = new Foo32();
        itfs[33] = new Foo33();
        itfs[34] = new Foo34();
        itfs[35] = new Foo35();
        itfs[36] = new Foo36();
        itfs[37] = new Foo37();
        itfs[38] = new Foo38();
        itfs[39] = new Foo39();
        itfs[40] = new Foo40();
        itfs[41] = new Foo41();
        itfs[42] = new Foo42();
        itfs[43] = new Foo43();
        itfs[44] = new Foo44();
        itfs[45] = new Foo45();
        itfs[46] = new Foo46();
        itfs[47] = new Foo47();
        itfs[48] = new Foo48();
        itfs[49] = new Foo49();

        StringBuilder sb      = new StringBuilder();
        int           counter = 0;

        for (int i = 0; i < 50; i++)
        {
            sb.Append(itfs[i].GetAString());
            counter += itfs[i].GetAnInt();
        }

        string expected = "Foo0Foo1Foo2Foo3Foo4Foo5Foo6Foo7Foo8Foo9Foo10Foo11Foo12Foo13Foo14Foo15Foo16Foo17Foo18Foo19Foo20Foo21Foo22Foo23Foo24Foo25Foo26Foo27Foo28Foo29Foo30Foo31Foo32Foo33Foo34Foo35Foo36Foo37Foo38Foo39Foo40Foo41Foo42Foo43Foo44Foo45Foo46Foo47Foo48Foo49";

        if (!expected.Equals(sb.ToString()))
        {
            Console.WriteLine("Concatenating strings from interface calls failed.");
            Console.Write("Expected: ");
            Console.WriteLine(expected);
            Console.Write(" Actual: ");
            Console.WriteLine(sb.ToString());
            return(Fail);
        }

        if (counter != 1225)
        {
            Console.WriteLine("Summing ints from interface calls failed.");
            Console.WriteLine("Expected: 1225");
            Console.Write("Actual: ");
            Console.WriteLine(counter);
            return(Fail);
        }

        return(100);
    }
コード例 #21
0
 public void Foo3(Foo3 input)
 {
 }
コード例 #22
0
    public static int test_0_regress_constrained_iface_call_enum()
    {
        var r = new ConstrainedEnum [10];

        return(Foo3 <ConstrainedEnum> .CompareTo(r));
    }
コード例 #23
0
    public static void Test()
    {
        var thing1 = new Foo3();

        Test(thing1, thing1);
    }