public void ShouldBeAbleToMockInAAAMode() { var adapter = new RhinoMockAdapter(MockMode.AAA); locator.Register(Mock<TestClassWithInterfaceDependencies>.Using(adapter)); var testClass = locator.GetInstance<TestClassWithInterfaceDependencies>(); testClass.TestInterface.Expect(i => i.GetSomeValue()).Return(1); var result = testClass.TestInterface.GetSomeValue(); Assert.AreEqual(1, result); }
public void AAAModeCanBeEnabledViaPropertySetter() { var adapter = new RhinoMockAdapter {MockingMode = MockMode.AAA}; locator.Register(Mock<TestClassWithInterfaceDependencies>.Using(adapter)); var testClass = locator.GetInstance<TestClassWithInterfaceDependencies>(); testClass.TestInterface.Expect(i => i.GetSomeValue()).Return(1); var result = testClass.TestInterface.GetSomeValue(); Assert.AreEqual(1, result); }
public void ShouldBeAbleToSetExpecationOnMockedInstance() { var adapter = new RhinoMockAdapter(); locator.Register(Mock<TestClassWithInterfaceDependencies>.Using(adapter)); var testClass = locator.GetInstance<TestClassWithInterfaceDependencies>(); using (adapter.Repository.Record()) { testClass.TestInterface.Expect(i => i.GetSomeValue()).Return(1); } var result = testClass.TestInterface.GetSomeValue(); Assert.AreEqual(1, result); }
public void ShouldBeAbleToStubInAAAMode() { var adapter = new RhinoMockAdapter(MockMode.AAA); locator.Register(Mock<TestClassWithClassDependencies>.Using(adapter)); var testClass = locator.GetInstance<TestClassWithInterfaceDependencies>(); testClass.Stub(c => c.GetSomeValue(Arg<int>.Is.Anything)).Return(1); var result = testClass.GetSomeValue(0); Assert.AreEqual(1, result); }
public void SpecialTypesTest() { var adapter = new RhinoMockAdapter {MockingMode = MockMode.AAA}; locator.Register(Mock<SpecialTestCase>.Using(adapter)); var testClass = locator.GetInstance<SpecialTestCase>(); var stringResult = testClass.StringInput; var intResult = testClass.IntInput; var boolResult = testClass.BoolInput; var enumReulst = testClass.EnumInput; var structResult = testClass.StructInput; Assert.AreEqual(string.Empty, stringResult); Assert.AreEqual(0, intResult); Assert.AreEqual(false, boolResult); Assert.AreEqual(TestEnum.Case1, enumReulst); Assert.IsTrue(structResult.x == 0 && structResult.y == 0); }
public void ShouldNotMockTypesAlreadyRegisteredInServiceLocator() { var adapter = new RhinoMockAdapter(); locator.Register(Given<ITestInterface>.Then<TestCase1>()); adapter.MockingMode = MockMode.AAA; locator.Register(Mock<ITestInterface>.Using(adapter, locator)); var testClass = locator.GetInstance<ITestInterface>(); Assert.IsInstanceOf(typeof(TestCase1), testClass); }