Example #1
0
        public void WhenAddingMockBehaviorToObject_ThenCanAddLambda()
        {
            object mock = new Mocked();

            mock.AddBehavior((m, n) => null, m => true);

            Assert.Equal(1, ((IMocked)mock).Mock.Behaviors.Count);
        }
Example #2
0
        public void WhenAddingMockBehaviorToObject_ThenCanAddInterface()
        {
            object mock = new Mocked();

            mock.AddBehavior(new TestMockBehavior());

            Assert.Equal(1, ((IMocked)mock).Mock.Behaviors.Count);
        }
Example #3
0
        public void WhenAddingMockBehavior_ThenCanAddLambda()
        {
            var mock = new Mocked();

            mock.AddBehavior((m, n) => null, m => true);

            Assert.Equal(1, mock.Mock.Behaviors.Count);
        }
Example #4
0
        public void WhenAddingMockBehavior_ThenCanAddInterface()
        {
            var mock = new Mocked();

            mock.AddBehavior(new TestMockBehavior());

            Assert.Equal(1, mock.Mock.Behaviors.Count);
        }
Example #5
0
        public void WhenAddingMockBehavior_ThenCanAddInterface()
        {
            var mock = new Mocked();

            mock.AddBehavior(new TestMockBehavior());

            Assert.Single(mock.Mock.Behaviors);
        }
Example #6
0
        public void WhenAddingMockBehavior_ThenCanAddLambda()
        {
            var mock = new Mocked();

            mock.AddBehavior((m, n) => null, m => true);

            Assert.Single(mock.Mock.Behaviors);
        }
Example #7
0
        public void WhenAddingMockBehavior_ThenCanAddInterface()
        {
            var mock     = new Mocked();
            var behavior = new TestMockBehavior();

            mock.AddBehavior(behavior);

            Assert.Contains(behavior, mock.Mock.Behaviors);
        }
Example #8
0
        public void RecordsInvocation()
        {
            var behavior = new MockTrackingBehavior();
            var mock     = new Mocked();

            behavior.Invoke(new MethodInvocation(mock, typeof(object).GetMethod(nameof(object.ToString))),
                            () => (m, n) => m.CreateValueReturn(null));

            Assert.Equal(1, mock.Mock.Invocations.Count);
        }
Example #9
0
        public void WhenInsertingMockBehaviorToObject_ThenCanAddLambda()
        {
            object mock = new Mocked();

            mock.AddBehavior((m, n) => null, m => true);
            mock.InsertBehavior(0, (m, n) => throw new NotImplementedException(), m => true);

            Assert.Equal(2, ((IMocked)mock).Mock.Behaviors.Count);
            Assert.Throws <NotImplementedException>(() => ((IMocked)mock).Mock.Behaviors[0].Invoke(null, null));
        }
Example #10
0
        public void WhenInsertingMockBehavior_ThenCanAddLambda()
        {
            var mock = new Mocked();

            mock.AddBehavior((m, n) => null, m => true);
            mock.InsertBehavior(0, (m, n) => throw new NotImplementedException(), m => true);

            Assert.Equal(2, mock.Mock.Behaviors.Count);
            Assert.Throws <NotImplementedException>(() => mock.Mock.Behaviors[0].Execute(null, null));
        }
Example #11
0
        public void WhenInsertingMockBehaviorToObject_ThenCanAddInterface()
        {
            object mock     = new Mocked();
            var    behavior = new TestMockBehavior();

            mock.AddBehavior((m, n) => null, m => true);
            mock.InsertBehavior(0, behavior);

            Assert.Equal(2, ((IMocked)mock).Mock.Behaviors.Count);
            Assert.Same(behavior, ((IMocked)mock).Mock.Behaviors[0]);
        }
Example #12
0
        public void WhenInsertingMockBehavior_ThenCanAddInterface()
        {
            var mock     = new Mocked();
            var behavior = new TestMockBehavior();
            var count    = mock.GetMock().Behaviors.Count;

            mock.AddBehavior((m, n) => null, m => true);
            mock.InsertBehavior(0, behavior);

            Assert.Equal(count + 2, mock.Mock.Behaviors.Count);
            Assert.Same(behavior, mock.Mock.Behaviors[0]);
        }