public void IndexPropertyWhenRefTypeAndNotFoundReturnNull() { IWithIndexers with = MockRepository.Mock <IWithIndexers>(); with.ExpectProperty(x => x["", 3]); Assert.Null(with["", 2]); }
public void IndexPropertyWhenRefTypeAndNotFoundReturnNull() { IWithIndexers x = (IWithIndexers)mocks.StrictMock(typeof(IWithIndexers)); Expect.Call(x["", 3]).PropertyBehavior(); mocks.ReplayAll(); Assert.Null(x["", 2]); }
public void IndexPropertyWhenValueTypeAndNotFoundThrows() { IWithIndexers with = MockRepository.Mock <IWithIndexers>(); with.ExpectProperty(x => x[1]); Assert.Throws <InvalidOperationException>( () => GC.KeepAlive(with[1])); }
public void IndexPropertyWhenRefTypeAndNotFoundReturnNull() { IWithIndexers with = MockRepository.Mock <IWithIndexers>(); with.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); with.ExpectProperty(x => x["", 3]); Assert.Null(with["", 2]); }
public void IndexPropertyWhenValueTypeAndNotFoundThrows() { IWithIndexers x = (IWithIndexers)mocks.StrictMock(typeof(IWithIndexers)); Expect.Call(x[1]).PropertyBehavior(); mocks.ReplayAll(); Assert.Throws <InvalidOperationException>( "Can't return a value for property Item because no value was set and the Property return a value type.", () => GC.KeepAlive(x[1])); }
public void IndexPropertyWhenValueTypeAndNotFoundThrows() { IWithIndexers with = MockRepository.Mock <IWithIndexers>(); with.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); with.ExpectProperty(x => x[1]); Assert.Throws <InvalidOperationException>( () => GC.KeepAlive(with[1])); }
public void IndexedPropertiesSupported() { IWithIndexers x = (IWithIndexers)mocks.StrictMock(typeof(IWithIndexers)); Expect.Call(x[1]).PropertyBehavior(); Expect.Call(x["", 1]).PropertyBehavior(); mocks.ReplayAll(); x[1] = 10; x[10] = 100; Assert.Equal(10, x[1]); Assert.Equal(100, x[10]); x["1", 2] = "3"; x["2", 3] = "5"; Assert.Equal("3", x["1", 2]); Assert.Equal("5", x["2", 3]); mocks.VerifyAll(); }
public void IndexedPropertiesSupported() { IWithIndexers with = MockRepository.Mock <IWithIndexers>(); //with.Expect(x => x[1]) // .PropertyBehavior(); //with.Expect(x => x["", 1]) // .PropertyBehavior(); with[1] = 10; with[10] = 100; Assert.Equal(10, with[1]); Assert.Equal(100, with[10]); with["1", 2] = "3"; with["2", 3] = "5"; Assert.Equal("3", with["1", 2]); Assert.Equal("5", with["2", 3]); with.VerifyAllExpectations(); }