当前位置: 首页>>代码示例>>C#>>正文


C# PrivateObject.GetFieldOrProperty方法代码示例

本文整理汇总了C#中PrivateObject.GetFieldOrProperty方法的典型用法代码示例。如果您正苦于以下问题:C# PrivateObject.GetFieldOrProperty方法的具体用法?C# PrivateObject.GetFieldOrProperty怎么用?C# PrivateObject.GetFieldOrProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PrivateObject的用法示例。


在下文中一共展示了PrivateObject.GetFieldOrProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConstructorTest

        public void ConstructorTest()
        {
            bool isFull = true;
            AnalysisThread target = CreateAnalysisThread(isFull);
            Assert.IsNotNull(target, "Constructor is broken");

            PrivateObject privateAnalysis = new PrivateObject(target, new PrivateType(typeof(AnalysisThread)));
            Assert.IsNotNull(privateAnalysis.GetFieldOrProperty("projects"), "Constructor did not set the projects.");
            Assert.IsTrue((bool)privateAnalysis.GetFieldOrProperty("full"), "Constructor did not set the full flag.");
            Assert.IsNotNull(privateAnalysis.GetFieldOrProperty("core"), "Constructor did not set the core.");
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:11,代码来源:AnalysisThreadTest.cs

示例2: ImapIdlerConstructorTest

        public void ImapIdlerConstructorTest()
        {
            var factory = new Mock<ImapClientFactory>(_configuration.Object);
            var idler = new ImapIdler(factory.Object);

            var imapIdlerPvtObject = new PrivateObject(idler);

            Assert.AreEqual(factory.Object, imapIdlerPvtObject.GetFieldOrProperty("Factory"));
            Assert.AreNotEqual(null, imapIdlerPvtObject.GetFieldOrProperty("Timeout"));
            Assert.AreNotEqual(null, imapIdlerPvtObject.GetFieldOrProperty("IntegrityCheckTimer"));
        }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:11,代码来源:ImapIdlerTests.cs

示例3: test

        static void test()
        {
            Class1.Item a = new Class1.Item();
            Type t = typeof(Class1);
            Type tinner = t.GetNestedType("Item", BindingFlags.NonPublic);
            PrivateObject o = new PrivateObject(tinner);
            o.SetFieldOrProperty("ID", "12345");

            PrivateObject class1 = new PrivateObject(typeof(Class1));
            dynamic list = (List<dynamic>)class1.GetFieldOrProperty("itemList");
            list.Add(o.Target);

            Console.WriteLine(class1.GetFieldOrProperty("GetFromListID"));
        }
开发者ID:Yuanxiangz,项目名称:WorkSpace,代码行数:14,代码来源:Program.cs

示例4: TestMethod2

        public void TestMethod2()
        {
            var t1 = DateTime.Now;
            var t2 = DateTime.Now.AddDays(-1);
            var emptyBook = new BookOrganizer.Book();
            var model = new AddBookViewModel(emptyBook);
            Book resBookManual = new Book()
            {
                Annotation = "Аннотация",
                Comment = "Комментарий",
                FinishTime = t1,
                StartTime = t2,
                Title = "Название",
                Pages = 100,
                Mark = 10,
                Year = 2016
            };

            model.Annotation = "Аннотация";
            model.Comment = "Комментарий";
            model.FinishTime = t1;
            model.StartTime = t2;
            model.Title = "Название";
            model.Pages = 100;
            model.Mark = 10;
            model.Year = 2016;

            var privateModel = new PrivateObject(model);

            var t = (privateModel.GetFieldOrProperty("book")) as Book;
            Assert.AreEqual(resBookManual, t);

            model.Author = "Пушкин А.С.";
            model.Genre = "Классика";
            resBookManual.Author = new Author() { Name = "Пушкин А.С." };
            resBookManual.Genre = new Genre() { Name = "Классика" };

            model.BookOut += (a) => { Assert.AreNotEqual(a, resBookManual); Assert.AreNotEqual(((Book)a).Author.Id, resBookManual.Author.Id); Assert.AreNotEqual(((Book)a).Genre.Id, resBookManual.Genre.Id); };
            model.SubmitCommand.Execute(null);

            var bookAutoCreatedButWithManualAuthorAndGenre = (privateModel.GetFieldOrProperty("book")) as Book;
            bookAutoCreatedButWithManualAuthorAndGenre.Author = new Author() { Name = "Пушкин А.С.", Id = 0 };
            bookAutoCreatedButWithManualAuthorAndGenre.Genre = new Genre() { Name = "Классика", Id = 0 };

            privateModel.SetFieldOrProperty("book", bookAutoCreatedButWithManualAuthorAndGenre);

            t = privateModel.GetFieldOrProperty("book") as Book;
            Assert.AreEqual(resBookManual, t);
        }
开发者ID:Nattican,项目名称:BookOrganizer,代码行数:49,代码来源:UnitTest1.cs

示例5: TestIfBombWithSizeFiveExplodesAsExpectedWhenOnTheTopLeft

        public void TestIfBombWithSizeFiveExplodesAsExpectedWhenOnTheTopLeft()
        {
            string testFieldSize = "6";

            Engine.FieldSizeUnitTestSetter = new StringReader(testFieldSize);
            Engine.StartMenu.IsStartGameChosen = true;
            Engine gameEngine = new Engine();
            Playfield testField = Playfield.Instance;
            testField.SetFieldSize(6);
            testField.InitializeEmptyField();
            testField[0, 0] = new BombCell(5);

            PrivateObject enginePrivateInstance = new PrivateObject(gameEngine);
            enginePrivateInstance.Invoke("HandleExplosion", testField[0, 0]);
            Playfield engineField = (Playfield)enginePrivateInstance.GetFieldOrProperty("playField");
            BombCell bomb = new BombCell(5);
            bomb.X = 0;
            bomb.Y = 0;
            engineField[0, 0] = bomb;

            enginePrivateInstance.Invoke("ChangeCurrentCell", 1, 1);
            enginePrivateInstance.Invoke("HandleExplosion", engineField[0, 0]);

            Assert.AreEqual(engineField[0, 1].CellType == CellType.BlownCell, true, "Expected that the cell on coordinates 4,5 is CellType.BlownCell. Received {0} ", engineField[4, 4].CellType);
        }
开发者ID:huuuskyyy,项目名称:Teamworks,代码行数:25,代码来源:EngineTests.cs

示例6: TestMethod1

        public void TestMethod1()
        {
            var book = new BookOrganizer.Book() { Title = "что-то", Author = new BookOrganizer.Author() { Name = "Пушкин" } };
            var b = new AddBookViewModel(book);

            PrivateObject obj = new PrivateObject(b);
            Assert.AreEqual(book, obj.GetFieldOrProperty("book") as BookOrganizer.Book);
        }
开发者ID:Nattican,项目名称:BookOrganizer,代码行数:8,代码来源:UnitTest1.cs

示例7: TestDeckCount

 public void TestDeckCount()
 {
     var testDeck = new PrivateObject(typeof(Deck));
     // Testing < and > instead of == for more robust feedback in case of failure.
     var cardsInTestDeck = new List<Card>((Stack<Card>)testDeck.GetFieldOrProperty("_cards"));
     Assert.IsFalse(cardsInTestDeck.Count < 52, "Deck Length Error", "There are less than 52 cards in the deck!");
     Assert.IsFalse(cardsInTestDeck.Count > 52, "Deck Length Error", "There are more than 52 cards in the deck!");
 }
开发者ID:christopher-taylor,项目名称:PokerHandEvaluator,代码行数:8,代码来源:TestDeckFunctionality.cs

示例8: EnsureDeckHasRightNumberOfSuites

 public void EnsureDeckHasRightNumberOfSuites()
 {
     var testDeck = new PrivateObject(typeof(Deck));
     var cardsInTestDeck = new List<Card>((Stack<Card>)testDeck.GetFieldOrProperty("_cards"));
     var result = cardsInTestDeck.GroupBy(card => card.Suit);
     Assert.IsFalse(result.Count() < 4, "Suits Error", "The deck contains less than four suits.");
     Assert.IsFalse(result.Count() > 4, "Suits Error", "The deck contains more than four suits.");
 }
开发者ID:christopher-taylor,项目名称:PokerHandEvaluator,代码行数:8,代码来源:TestDeckFunctionality.cs

示例9: EnsureDeckHasRightNumberOfValues

 public void EnsureDeckHasRightNumberOfValues()
 {
     var testDeck = new PrivateObject(typeof(Deck));
     var cardsInTestDeck = new List<Card>((Stack<Card>)testDeck.GetFieldOrProperty("_cards"));
     var result = cardsInTestDeck.GroupBy(card => card.Value);
     Assert.IsFalse(result.Count() < 13, "Value Error", "The deck contains less than thirteen values.");
     Assert.IsFalse(result.Count() > 13, "Value Error", "The deck contains more than thirteen values.");
 }
开发者ID:christopher-taylor,项目名称:PokerHandEvaluator,代码行数:8,代码来源:TestDeckFunctionality.cs

示例10: ConstructorTest

        public void ConstructorTest()
        {
            // Execute metod under test first time
            TaskProvider target = new TaskProvider(this.serviceProvider);
            Assert.IsNotNull(target, "Unable to instantiate TaskProvider.");

            PrivateObject taskProvider = new PrivateObject(target, new PrivateType(typeof(TaskProvider)));
            Assert.IsNotNull(taskProvider.GetFieldOrProperty("serviceProvider"), "TaskProvider.provider returned null");
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:9,代码来源:TaskProviderTest.cs

示例11: GetInstanceTest

        public void GetInstanceTest()
        {
            VSWindows instance = VSWindows.GetInstance(this.serviceProvider);
            PrivateObject actual = new PrivateObject(instance, new PrivateType(typeof(VSWindows)));

            Assert.IsNotNull(instance, "VSWindows.GetInstance() returned null.");
            Assert.IsNotNull(this.serviceProvider, "serviceProvider is null.");

            Assert.AreEqual(this.serviceProvider, (MockServiceProvider)actual.GetFieldOrProperty("serviceProvider"), "Service provider was not set correctly");
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:10,代码来源:VSWindowsTest.cs

示例12: ConstructorTest

        public void ConstructorTest()
        {
            try
            {
                bool isFull = true;
                AnalysisThread target = CreateAnalysisThread(isFull);
                Assert.IsNotNull(target, "Constructor is broken");

                PrivateObject privateAnalysis = new PrivateObject(target, new PrivateType(typeof(AnalysisThread)));
                Assert.IsNotNull(privateAnalysis.GetFieldOrProperty("projects"), "Constructor did not set the projects.");
                Assert.IsTrue((bool)privateAnalysis.GetFieldOrProperty("full"), "Constructor did not set the full flag.");
                Assert.IsNotNull(privateAnalysis.GetFieldOrProperty("core"), "Constructor did not set the core.");
            }
            catch (Exception ex)
            {
                // Use try catch to test a workaround on CI build (AppVeyor)
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:Visual-Stylecop,项目名称:Visual-StyleCop,代码行数:19,代码来源:AnalysisThreadTest.cs

示例13: TestPrivateMember

        public void TestPrivateMember()
        {
            //arrange
            string name = "Abhishek";
            int age = 30;
            Salary osalary = new Salary(name, age);

            //act
            PrivateObject pObj = new PrivateObject(osalary);

            //assert
            Assert.AreEqual<int>(age, Convert.ToInt32(pObj.GetField("age")));
            Assert.AreEqual<string>(name, pObj.GetFieldOrProperty("name") as string);
        }
开发者ID:solondon,项目名称:VisualStudio2013andNETCookbookCode,代码行数:14,代码来源:SalaryPrivateTests.cs

示例14: FreshenMailBoxTest

        public void FreshenMailBoxTest()
        {
            //setup private object
            var pvt = new PrivateObject(_imapMailBox);

            pvt.SetFieldOrProperty("_imapWorker", _worker.Object);

            //* start the freshen *//
            var result = (Task<bool>)pvt.Invoke("FreshenMailBox");

            _worker.Verify(x => x.FreshenMailBox(It.IsAny<string>()));
            Assert.IsTrue(result.Result);
            Assert.IsFalse((bool) pvt.GetFieldOrProperty("Freshening"));
        }
开发者ID:ptfuller,项目名称:InboxWatcher,代码行数:14,代码来源:ImapMailBoxTests.cs

示例15: DTEPropertyTest

 public void DTEPropertyTest()
 {
     try
     {
         VSWindows instance = VSWindows.GetInstance(this.serviceProvider);
         PrivateObject actual = new PrivateObject(instance, new PrivateType(typeof(VSWindows)));
         Assert.IsNotNull((MockDTE)actual.GetFieldOrProperty("DTE"), "DTE property was null");
     }
     catch (Exception ex)
     {
         // Use try catch to test a workaround on CI build (AppVeyor)
         Console.WriteLine(ex.Message);
     }
 }
开发者ID:Visual-Stylecop,项目名称:Visual-StyleCop,代码行数:14,代码来源:VSWindowsTest.cs


注:本文中的PrivateObject.GetFieldOrProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。