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); }
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 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 AAA_Mode_Can_Be_Enabled_Via_Property_Setter() { var adapter = new RhinoMockAdapter(); adapter.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 Should_Be_Able_To_Stub_On_Objects() { var adapter = new RhinoMockAdapter(); locator.Register(Mock <TestClassWithClassDependencies> .Using(adapter)); var testClass = locator.GetInstance <TestClassWithInterfaceDependencies>(); using (adapter.Repository.Record()) { testClass.Stub(c => c.GetSomeValue(Arg <int> .Is.Anything)).Return(1); } var result = testClass.GetSomeValue(0); 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 Special_Types_Test() { var adapter = new RhinoMockAdapter(); adapter.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); }