Ejemplo n.º 1
0
        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            MockRepository mocks = new MockRepository();
            ISomeService m_SomeServiceMock = mocks.StrictMock<ISomeService>();
            SomeClient sut = new SomeClient(m_SomeServiceMock);

            using (mocks.Ordered())
            {
                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<string>(null, null);
                });
                LastCall.IgnoreArguments();

                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething<DateTime>(null, default(DateTime));  // can't use null here, because it's a value type!
                });
                LastCall.IgnoreArguments();

            }
            mocks.ReplayAll();

            // test
            sut.DoSomething();

            // verification
            mocks.VerifyAll();

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
Ejemplo n.º 2
0
        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            MockRepository mocks             = new MockRepository();
            ISomeService   m_SomeServiceMock = mocks.StrictMock <ISomeService>();
            SomeClient     sut = new SomeClient(m_SomeServiceMock);

            using (mocks.Ordered())
            {
                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething <string>(null, null);
                });
                LastCall.IgnoreArguments();

                Expect.Call(delegate
                {
                    m_SomeServiceMock.DoSomething <DateTime>(null, default(DateTime));                     // can't use null here, because it's a value type!
                });
                LastCall.IgnoreArguments();
            }
            mocks.ReplayAll();

            // test
            sut.DoSomething();

            // verification
            mocks.VerifyAll();

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
Ejemplo n.º 3
0
        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            ISomeService m_SomeServiceMock = MockRepository.GenerateStrictMock<ISomeService>();
            SomeClient sut = new SomeClient(m_SomeServiceMock);

            m_SomeServiceMock.Expect(x => x.DoSomething(null, default(string))).IgnoreArguments();
            m_SomeServiceMock.Expect(x => x.DoSomething(null, default(DateTime))).IgnoreArguments();

            // test
            sut.DoSomething();

            // verification
            m_SomeServiceMock.AssertWasCalled(x => x.DoSomething(null, default(string)), o => o.IgnoreArguments())
                .Before(m_SomeServiceMock.AssertWasCalled(x => x.DoSomething(null, default(DateTime)), o => o.IgnoreArguments()));
            m_SomeServiceMock.VerifyAllExpectations();
        }
Ejemplo n.º 4
0
        public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
        {
            // setup
            ISomeService m_SomeServiceMock = MockRepository.Mock <ISomeService>();
            SomeClient   sut = new SomeClient(m_SomeServiceMock);

            m_SomeServiceMock.Expect(x => x.DoSomething <string>(null, null))
            .IgnoreArguments();

            m_SomeServiceMock.Expect(x => x.DoSomething <DateTime>(null, default(DateTime)))
            .IgnoreArguments();

            // test
            sut.DoSomething();

            // verification
            m_SomeServiceMock.VerifyExpectations(true);

            // cleanup
            m_SomeServiceMock = null;
            sut = null;
        }
		public void ShouldIgnoreArgumentsOnGenericCallWhenTypeIsStruct()
		{
			// setup
			ISomeService m_SomeServiceMock = MockRepository.Mock<ISomeService>();
			SomeClient sut = new SomeClient(m_SomeServiceMock);

            m_SomeServiceMock.Expect(x => x.DoSomething<string>(null, null))
                .IgnoreArguments();

            m_SomeServiceMock.Expect(x => x.DoSomething<DateTime>(null, default(DateTime)))
                .IgnoreArguments();
            
            // test
			sut.DoSomething();

			// verification
            m_SomeServiceMock.VerifyExpectations(true);

			// cleanup
			m_SomeServiceMock = null;
			sut = null;
		}