Пример #1
0
		public RoleRef (RoleBase role)
		{
			if(null == role)
				throw new ArgumentNullException("role");
			Role = role;
			_refs = 0;
		}
Пример #2
0
        public void Decrease_underZero_throwsInvalidOperationException()
        {
            // arrange:
            RoleBase role    = MockRepository.GenerateStrictMock <RoleBase>();
            RoleRef  roleRef = new RoleRef(role);

            // assert:
            Assert.Throws <InvalidOperationException>(delegate { roleRef.Decrease(); });
        }
Пример #3
0
 public RoleRef(RoleBase role)
 {
     if (null == role)
     {
         throw new ArgumentNullException("role");
     }
     Role  = role;
     _refs = 0;
 }
Пример #4
0
        public void Ctor_withRole_works()
        {
            // arrange:
            RoleBase role = MockRepository.GenerateStrictMock <RoleBase>();

            // act:
            RoleRef roleRef = new RoleRef(role);

            // assert:
            Assert.AreSame(role, roleRef.Role);
        }
Пример #5
0
        public void Dispose_willDisposeTheRole()
        {
            // arrange:
            RoleBase role = MockRepository.GenerateStrictMock <RoleBase>();

            role.Expect(r => r.Dispose()).Repeat.Once();
            RoleRef roleRef = new RoleRef(role);

            // assert:
            roleRef.Dispose();
        }
Пример #6
0
        public void Increase_increaseTheNumberOfReferences()
        {
            // arrange:
            RoleBase role    = MockRepository.GenerateStrictMock <RoleBase>();
            RoleRef  roleRef = new RoleRef(role);

            // assert:
            for (int i = 0; i < 100; ++i)
            {
                Assert.AreEqual(i + 1, roleRef.Increase());
            }
        }