public void ExpectAllPropertiesCalled() { var person = MockRepository.GenerateStrictMock <IPerson>(); //person.Expect(x => x.FirstName).Return(null); //person.Expect(x => x.LastName).Return(null); //person.Expect(x => x.Birthday).Return(new DateTime()); //person.Expect(x => x.Heigth).Return(0); foreach (var propertyInfo in typeof(IPerson).GetProperties().Where(p => Attribute.IsDefined(p, typeof(ShouldBeCalledAttribute)))) { ExpectPropertyGet(person, propertyInfo); } PersonHasher.GetHashCode(person); person.VerifyAllExpectations(); }
public void ExpectAllPropertiesCalled() { var person = Mock.Create <IPerson>(Behavior.Strict); //Mock.Arrange(person, x => x.FirstName).Returns((string)null).MustBeCalled(); //Mock.Arrange(() => person.LastName).Returns((string)null).MustBeCalled(); //Mock.Arrange(() => person.Birthday).Returns(new DateTime()).MustBeCalled(); //Mock.Arrange(() => person.Heigth).Returns(0).MustBeCalled(); foreach (var propertyInfo in typeof(IPerson).GetProperties().Where(p => Attribute.IsDefined(p, typeof(ShouldBeCalledAttribute)))) { ExpectPropertyGet(person, propertyInfo); } PersonHasher.GetHashCode(person); Mock.Assert(person); }
public void ExpectAllPropertiesCalled() { var person = new Mock <IPerson>(MockBehavior.Strict); //person.Setup(x => x.FirstName).Returns((string)null).Verifiable(); //person.Setup(x => x.LastName).Returns((string)null).Verifiable(); //person.Setup(x => x.Birthday).Returns(new DateTime()).Verifiable(); //person.Setup(x => x.Heigth).Returns(0).Verifiable(); foreach (var propertyInfo in typeof(IPerson).GetProperties().Where(p => Attribute.IsDefined(p, typeof(ShouldBeCalledAttribute)))) { ExpectPropertyGet(person, propertyInfo); } PersonHasher.GetHashCode(person.Object); person.Verify(); }
public void ExpectAllPropertiesCalled() { var person = Substitute.For <IPerson>(); PersonHasher.GetHashCode(person); //_ = person.Received().Heigth; //_ = SubstituteExtensions.Received(person).FirstName; foreach (var propertyInfo in typeof(IPerson).GetProperties()) { if (Attribute.IsDefined(propertyInfo, typeof(ShouldBeCalledAttribute))) { VerifyPropertyGet(person, propertyInfo); } else { VerifyNoPropertyGet(person, propertyInfo); } } }