Beispiel #1
0
        public void ResolveObject__MockDependenciesInitiated()
        {
            ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>();

            Assert.IsNotNull(od.firstObject);
            Assert.IsNotNull(od.secondObject);
        }
Beispiel #2
0
        public void ResolveObjectWithSpecificImpl__OneDependencyIsNotMocked()
        {
            container.RegisterType <IFirstObject, FirstObjectImpl>();
            ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>();

            Assert.IsInstanceOfType(od.firstObject, typeof(FirstObjectImpl));
            Assert.IsNotNull(od.secondObject);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        public void SecondObjectIsAStrictMock__ExceptionThrownOnCallingNotExpectedMethod()
        {
            mocknity.SetStrategy <StrictRhinoMocksBuilderStrategy>(typeof(ISecondObject));
            ObjectWithDependencies od = container.Resolve <ObjectWithDependencies>();

            mocknity.getRepository().ReplayAll();
            od.secondObject.HelloWorld();
            mocknity.getRepository().VerifyAll();
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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();
        }