public void ResolveObject__MockDependenciesInitiated() { ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); Assert.IsNotNull(od.firstObject); Assert.IsNotNull(od.secondObject); }
public void ResolveObjectWithSpecificImpl__OneDependencyIsNotMocked() { container.RegisterType <IFirstObject, FirstObjectImpl>(); ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); Assert.IsInstanceOfType(od.firstObject, typeof(FirstObjectImpl)); Assert.IsNotNull(od.secondObject); }
public void ResolveObjectWithExpectedCall__GetDesiredResult() { ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); Expect.Call(od.secondObject.HelloWorld()).Return("I'm the first of none"); mocknity.getRepository().ReplayAll(); Assert.AreEqual("I'm the first of none", od.PokeSecond()); mocknity.getRepository().VerifyAll(); }
public void SecondObjectIsAStrictMock__ExceptionThrownOnCallingNotExpectedMethod() { mocknity.SetStrategy <StrictRhinoMocksBuilderStrategy>(typeof(ISecondObject)); ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); mocknity.getRepository().ReplayAll(); od.secondObject.HelloWorld(); mocknity.getRepository().VerifyAll(); }
public void SecondObjectIsADynamicCall__AcceptsUnexpectedCall() { // dynamic mocking is a default strategy in mocknity ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); mocknity.getRepository().ReplayAll(); // doesn't raise exceptions od.secondObject.HelloWorld(); mocknity.getRepository().VerifyAll(); }
public void SecondObjectIsAStub__CanChangeProperties() { mocknity.SetStrategy <StubRhinoMocksBuilderStrategy>(typeof(ISecondObject)); ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>(); mocknity.getRepository().ReplayAll(); od.secondObject.MyProperty = 42; Assert.AreEqual(42, od.secondObject.MyProperty); mocknity.getRepository().VerifyAll(); }