public void TestSingleFamily()
        {
            var assert = new TypeAssert <SingleFamily>();

            assert.Extends <Home>();

            assert.Property <string>(
                "Address",
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.GetProperty
                ).DeclaredIn <Home>();

            assert.Property <int>(
                "YearBuilt",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                ).DeclaredIn <Home>();

            assert.Property <decimal>(
                "Price",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                ).DeclaredIn <Home>();

            assert.Constructor(
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param <string>("address"),
                new Param <int>("yearBuilt"),
                new Param <decimal>("price")
                );

            assert.NonConstructor(
                BindingFlags.Public |
                BindingFlags.Instance
                );

            assert.Property <decimal>(
                "TotalCost",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                ).DeclaredIn <Home>().Override();

            assert.Method <decimal>(
                "GetRate",
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param <int>("numberOfPeriods")
                ).DeclaredIn <SingleFamily>().Override();

            assert.Method <string>(
                "ToString",
                BindingFlags.Public |
                BindingFlags.Instance
                ).DeclaredIn <SingleFamily>().Override();
        }
        public void Constructor()
        {
#if !DEBUG
        Assert.Multiple(() => {
#endif
            var assert = new TypeAssert<CheckingAccount>();
            assert.Extends<Account>();
            assert.Constructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param<decimal>("initialBalance"),
                new Param<decimal>("transactionFee")
            );

            assert.NonConstructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param<decimal>("initialBalance")
            );
            // new CheckingAccount(11.5m, -0.05m);
            assert.Catch<ArgumentOutOfRangeException>(() => assert.New(11.5m, -0.05m));
#if !DEBUG
        });
#endif
        }
        public void TestHomeClass()
        {
            var assert = new TypeAssert <Home>();

            assert.Constructor(
                BindingFlags.NonPublic |
                BindingFlags.Instance,
                new Param <string>("address"),
                new Param <int>("yearBuilt"),
                new Param <decimal>("price")
                ).Protected();

            assert.NonConstructor(
                BindingFlags.Public |
                BindingFlags.Instance
                );

            assert.Property <string>(
                "Address",
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.GetProperty);

            assert.Property <int>(
                "YearBuilt",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                );

            assert.Property <decimal>(
                "Price",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                );

            assert.Property <decimal>(
                "TotalCost",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
                ).Virtual();

            assert.Method <decimal>(
                "GetRate",
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param <int>("numberOfPeriods")
                ).Virtual();

            assert.Method <string>(
                "ToString",
                BindingFlags.Public |
                BindingFlags.Instance
                ).Override();
        }
示例#4
0
        public void TestClass()
        {
#if !DEBUG
        Assert.Multiple(() => {
#endif
            var assert = new TypeAssert<Square>();
            assert.Extends<Rectangle>();

            assert.Constructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param<int>("width")
            );

            assert.NonConstructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param<int>("width"),
                new Param<int>("height")
            );

            assert.Property<int>(
                "Width",
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.GetProperty
            ).DeclaredIn<EmptyTextShape>();

            assert.Property<int>(
                "Height",
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.GetProperty
            ).DeclaredIn<EmptyTextShape>();

            assert.Property<string>(
                "Name",
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.GetProperty
            ).DeclaredIn<EmptyTextShape>();

            assert.Method<decimal>(
              "Area",
              BindingFlags.Instance |
              BindingFlags.Public)
                  .DeclaredIn<Rectangle>();

            assert.Method<decimal>(
              "Perimeter",
              BindingFlags.Instance |
              BindingFlags.Public)
                  .DeclaredIn<Rectangle>();
#if !DEBUG
        });
#endif
        }
示例#5
0
        public void Constructor()
        {
            var assert = new TypeAssert <SavingsAccount>();

            assert.Extends <Account>();
            assert.Constructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param <decimal>("initialBalance"),
                new Param <decimal>("transactionFee")
                );

            assert.NonConstructor(
                BindingFlags.Instance |
                BindingFlags.Public,
                new Param <decimal>("initialBalance")
                );
            // new SavingsAccount(11.5m, -0.05m);
            assert.Catch <ArgumentOutOfRangeException>(() => assert.New(11.5m, -0.05m));
        }
示例#6
0
        public void TestCondo()
        {
#if !DEBUG
        Assert.Multiple(() => {
#endif
            var assert = new TypeAssert<Condo>();
            assert.Extends<Home>();
            assert.Implements<IRental>();
            assert.NonAbstract();

            assert.Property<string>(
               "Address",
               BindingFlags.Instance |
               BindingFlags.Public |
               BindingFlags.GetProperty
            ).DeclaredIn<Home>();

            assert.Property<int>(
                "YearBuilt",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            ).DeclaredIn<Home>();

            assert.Property<decimal>(
                "Price",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            ).DeclaredIn<Home>();

            assert.Property<decimal>(
                "Fee",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty);

            assert.Property<string>(
                "UnitNumber",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            );

            assert.Property<bool>(
                "IsRental",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty |
                BindingFlags.SetProperty
            );

            assert.NonConstructor(
                BindingFlags.Public |
                BindingFlags.Instance
            );

            assert.Constructor(
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param<string>("address"),
                new Param<int>("yearBuilt"),
                new Param<decimal>("price"),
                new Param<string>("unitNumber"),
                new Param<decimal>("fee"),
                new Param<bool>("isRental") { Default = false }
            );

            assert.NonConstructor(
                BindingFlags.Public |
                BindingFlags.Instance
            );

            assert.Property<decimal>(
                "TotalCost",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            ).Override().DeclaredIn<Condo>(); ;

            assert.Method<decimal>(
                "GetRate",
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param<int>("numberOfPeriods")
            ).Override().DeclaredIn<Condo>();

            assert.Method<decimal>(
                "GetMonthlyRate",
                BindingFlags.Public |
                BindingFlags.Instance
            );
#if !DEBUG
    });
#endif
        }
示例#7
0
        public void TestHome()
        {
#if !DEBUG
        Assert.Multiple(() => {
#endif
            var assert = new TypeAssert<Home>();
            assert.Abstract();
            assert.Property<string>(
              "Address",
              BindingFlags.Instance |
              BindingFlags.Public |
              BindingFlags.GetProperty);

            assert.Property<int>(
                "YearBuilt",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            );

            assert.Property<decimal>(
                "Price",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            );

            assert.Constructor(
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param<string>("address"),
                new Param<int>("yearBuilt"),
                new Param<decimal>("price")
            );

            assert.NonConstructor(
                BindingFlags.Public |
                BindingFlags.Instance
            );

            assert.Property<decimal>(
                "TotalCost",
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.GetProperty
            ).Virtual();

            assert.Method<decimal>(
                "GetRate",
                BindingFlags.Public |
                BindingFlags.Instance,
                new Param<int>("numberOfPeriods")
            ).Abstract();

            assert.Method<string>(
                "ToString",
                BindingFlags.Public |
                BindingFlags.Instance
            ).Override();

#if !DEBUG
        });
#endif
        }