public void GetReturnsMockForAMockedAbstract() { var mock = new Mock <FooBase>(); var mocked = mock.Object; Assert.Same(mock, Mock.Get(mocked)); }
public void GetReturnsMockForAMocked() { var mock = new Mock <IFoo>(); var mocked = mock.Object; Assert.Same(mock, Mock.Get(mocked)); }
public void MockOfMockedClassWithCtorShouldReturnSame() { Mock <FooWithCtor> mock = new Mock <FooWithCtor>(5); IMocked <FooWithCtor> mocked = mock.Object as IMocked <FooWithCtor>; Assert.Same(mock, mocked.Mock); }
public void MockOfMockedClassShouldReturnSame() { Mock <Foo> mock = new Mock <Foo>(); IMocked <Foo> mocked = mock.Object as IMocked <Foo>; Assert.Same(mock, mocked.Mock); }
public void MockOfMockedInterfaceShouldReturnSame() { Mock <IFoo> mock = new Mock <IFoo>(); IMocked <IFoo> mocked = mock.Object as IMocked <IFoo>; Assert.Same(mock, mocked.Mock); }
public void CachesProvidedValue() { var mock = new Mock <IFoo>(); var provider = new MockDefaultValueProvider(mock); var value1 = provider.ProvideDefault(typeof(IFoo).GetProperty("Bar").GetGetMethod()); var value2 = provider.ProvideDefault(typeof(IFoo).GetProperty("Bar").GetGetMethod()); Assert.Same(value1, value2); }
public void Test() { var mock = new Mock <IDisposable>().As <IComponent>(); mock.SetupAllProperties(); ISite site = new FooSite(); mock.Object.Site = site; Assert.Same(site, mock.Object.Site); }
public void RetrievesSameMockForProperty() { var mock = new Mock <IFoo> { DefaultValue = DefaultValue.Mock }; var b1 = mock.Object.Bar; var b2 = mock.Object.Bar; Assert.Same(b1, b2); }
public void DoesNotRaiseEventOnSubObject() { var mock = new Mock <IParent> { DefaultValue = DefaultValue.Mock }; bool raised = false; mock.Object.Adder.Added += (sender, args) => raised = true; Assert.Same(mock.Object.Adder, mock.Object.Adder); mock.Raise(p => p.Adder.Added += null, EventArgs.Empty); Assert.False(raised); }
public void StubsAllProperties() { var mock = new Mock <IFoo>(); mock.SetupAllProperties(); mock.Object.ValueProperty = 5; Assert.Equal(5, mock.Object.ValueProperty); var obj = new object(); mock.Object.Object = obj; Assert.Same(obj, mock.Object.Object); var bar = new Mock <IBar>(); mock.Object.Bar = bar.Object; Assert.Same(bar.Object, mock.Object.Bar); }