示例#1
0
        public void TestMethodWinRTCompNet()
        {
            // C# WinRT Person
            WinRTCompNet.Person person = new WinRTCompNet.Person(NAME_DARTH, SURNAME_VADOR);

            Assert.AreEqual(NAME_DARTH, person.Name);

            // C++ WinRT IPerson interface
            WinRTCompV2.IPerson personItf;

            // C++ WinRT Person class
            WinRTCompV2.Person personV2 = new WinRTCompV2.Person(NAME_LUKE, SURNAME_SKYWALKER);

            // the interface is now implemented by the C# person
            personItf = person;
            Assert.AreEqual(NAME_DARTH, personItf.Name);
            Assert.AreEqual(SURNAME_VADOR, personItf.Surname);

            // the interface is now implemented by the C++ Person
            personItf = personV2;
            Assert.AreEqual(NAME_LUKE, personItf.Name);
            Assert.AreEqual(SURNAME_SKYWALKER, personItf.Surname);

            // Create a C# Address and Citizen
            WinRTCompNet.Address addressDarth = new WinRTCompNet.Address(STREET_DARTH, ZIP_DARTH, CITY_DARTH);
            WinRTCompNet.Citizen citizenDarth = new WinRTCompNet.Citizen(NAME_DARTH, SURNAME_VADOR, addressDarth);

            // This method is only in the C# Citizen component. The compiler has created
            // a default interface for that component. This interface is NOT ICitizen
            string display = citizenDarth.FormatDisplay();

            // Put the C# Address in the IAddress C++ interface
            WinRTCompV2.IAddress addressItf = citizenDarth.Address;
            Assert.AreEqual(STREET_DARTH, addressItf.Street);
            Assert.AreEqual(ZIP_DARTH, addressItf.ZipCode);
            Assert.AreEqual(CITY_DARTH, addressItf.City);

            // Put the C# Citizen in the ICitizen C++ interface. The method FormatDisplay() is not visible
            WinRTCompV2.ICitizen citizenItf = citizenDarth;
            Assert.AreEqual(NAME_DARTH, citizenItf.Name);
            Assert.AreEqual(SURNAME_VADOR, citizenItf.Surname);
        }
示例#2
0
        public void TestMethodWinRTCompNetDll()
        {
            // C# WinRT Person
            WinRTCompNetDll.Person person = new WinRTCompNetDll.Person(NAME_DARTH, SURNAME_VADOR);

            Assert.IsTrue(person.CanSave());

            // Note: Because the interface is implemented explicitly, it is necessary to put the
            // instance in the IPerson interface to access it.
            // C++ WinRT IPerson interface
            WinRTCompV2.IPerson personItf;

            // C++ WinRT Person class
            WinRTCompV2.Person personV2 = new WinRTCompV2.Person(NAME_LUKE, SURNAME_SKYWALKER);

            // the interface is now implemented by the C# person
            personItf = person;
            Assert.AreEqual(NAME_DARTH, personItf.Name);
            Assert.AreEqual(SURNAME_VADOR, personItf.Surname);

            // the interface is now implemented by the C++ Person
            personItf = personV2;
            Assert.AreEqual(NAME_LUKE, personItf.Name);
            Assert.AreEqual(SURNAME_SKYWALKER, personItf.Surname);

            // Create a C# Address and Citizen
            WinRTCompNetDll.Address addressDarth = new WinRTCompNetDll.Address(STREET_DARTH, ZIP_DARTH, CITY_DARTH);
            WinRTCompNetDll.Citizen citizenDarth = new WinRTCompNetDll.Citizen(NAME_DARTH, SURNAME_VADOR, addressDarth);

            // Put the C# Citizen in the ICitizen C++ interface. The method FormatDisplay() is not visible
            WinRTCompV2.ICitizen citizenItf = citizenDarth;
            Assert.AreEqual(NAME_DARTH, citizenItf.Name);
            Assert.AreEqual(SURNAME_VADOR, citizenItf.Surname);

            // Put the C# Address in the IAddress C++ interface
            WinRTCompV2.IAddress addressItf = citizenItf.Address;
            Assert.AreEqual(STREET_DARTH, addressItf.Street);
            Assert.AreEqual(ZIP_DARTH, addressItf.ZipCode);
            Assert.AreEqual(CITY_DARTH, addressItf.City);
        }
示例#3
0
        public void TestPersonV2()
        {
            WinRTCompV2.IPerson person = new WinRTCompV2.Person();

            Assert.IsFalse(person.CanSave());

            person.Name = TestData.TEXT_NAME1;
            person.Surname = TestData.TEXT_SURNAME1;

            Assert.IsTrue(person.CanSave());

            Assert.AreEqual(TestData.TEXT_NAME1, person.Name);
            Assert.AreEqual(TestData.TEXT_SURNAME1, person.Surname);

            person = new WinRTCompV2.Person(TestData.TEXT_NAME2, TestData.TEXT_SURNAME1);

            Assert.IsTrue(person.CanSave());

            Assert.AreEqual(TestData.TEXT_NAME2, person.Name);
            Assert.AreEqual(TestData.TEXT_SURNAME1, person.Surname);

            person.Name = TestData.TEXT_NAME1;

            Assert.AreEqual(TestData.TEXT_NAME1, person.Name);
            Assert.AreEqual(TestData.TEXT_SURNAME1, person.Surname);
        }