예제 #1
0
        public void FakeTest1()
        {
            //arrange
            var fake      = new Fake <IParentInterface>();
            var presenter = new TestPresenter(fake.MockObject);

            //act
            presenter.SetPropertyOfMockToInternalValue();
            presenter.SetIndexerPropertyOfMockToInternalValue();
            presenter.BeginInvoke();
            presenter.HookUpStandardEvent1();

            //assert
            fake.PropertyIs(_ => _.ReadWriteObjectProperty = new Version(5, 6, 7, 8));
            fake.Property(_ => _.ReadWriteObjectProperty).Is(new Version(5, 6, 7, 8));
        }
예제 #2
0
        private void ArrangeTest1(Mock <IParentInterface> mock)
        {
            var expectations = new Expectations(5);

            expectations[0] = mock.Arrange(_ => _.Method(3)).WillReturn(true);
            expectations[1] = mock.Arrange(_ => _.MethodVoid(new Version(1, 1, 1, 1))).With(new Version(3, 3, 3, 3));
            expectations[2] = mock.Arrange(_ => _.ReadOnlyValueProperty).WillReturn(3);
            expectations[3] = mock.Arrange(_ => _.WriteOnlyObjectProperty = new Version(2, 2, 2, 2));
            expectations[4] = mock.Arrange(_ => _.StandardEvent1 += null);

            var p  = new TestPresenter(mock.MockObject);
            var b1 = p.CallMethod(3);

            p.CallVoidMethod(new Version(3, 3, 3, 3));
            var b2 = p.GetReadOnlyValueProperty();

            p.AssignWriteOnlyObjectProperty(new Version(2, 2, 2, 2));
            p.HookUpStandardEvent1();

            expectations.ForEach(_ => _.Assert());
            Assert.IsTrue(b1);
            Assert.AreEqual(3, b2);
        }