# CallOriginal

**CallOriginal** behavior makes the mock call the original implementation of the mocked type for every method or property that has no explicit arrangement. Use it for partial mocking: create a `Behavior.CallOriginal` mock, then arrange only the specific methods you want to override. All other calls execute the actual code.

## Syntax

`Mock.Create<T>(Behavior.CallOriginal);`

## Examples

### Basic CallOriginal Example

Assume the following class:

```C#
public class Log
{
    public virtual void Info()
    {
        throw new NotImplementedException();
    }
}
```

```VB
Public Class Log
    Public Overridable Sub Info()
        Throw New NotImplementedException()
    End Sub
End Class
```

To show how `CallOriginal` mocks behave, we have the next example:

```C#
[TestMethod]
[ExpectedException(typeof(NotImplementedException))]
public void ShouldThrowAnExpectedException()
{
    // Arrange
    var log = Mock.Create<Log>(Behavior.CallOriginal);

    // Act
    log.Info();
}
```

```VB
<TestMethod> _
<ExpectedException(GetType(NotImplementedException))> _
Public Sub ShouldThrowAnExpectedException()
    ' Arrange
    Dim log = Mock.Create(Of Log)(Behavior.CallOriginal)

    ' Act
    log.Info()
End Sub
```

Here, we create a mock of the `Log` class, with `Behavior.CallOriginal` and call a not implemented method. This method follows its original logic and throws a `NotImplementedException`.

### Arranging CallOriginal Mock

We are free to further arrange mocks with `Behavior.CallOriginal`, as shown in the next example:

```C#
public class FooBase
{
    public string GetString(string str)
    {
        return str;
    }
}
```

```VB
Public Class FooBase
    Public Function GetString(str As String) As String
        Return str
    End Function
End Class
```

```C#
[TestMethod]
public void ShouldAssertAgainstOriginalAndArrangedExpectations()
{
    // Arrange
    var foo = Mock.Create<FooBase>(Behavior.CallOriginal);

    Mock.Arrange(() => foo.GetString("y")).Returns("z");

    // Act
    var actualX = foo.GetString("x");
    var actualY = foo.GetString("y");

    var expectedX = "x";
    var expectedY = "z";

    // Assert
    Assert.AreEqual(expectedX, actualX);
    Assert.AreEqual(expectedY, actualY);
}
```

```VB
<TestMethod> _
Public Sub ShouldAssertAgainstOriginalAndArrangedExpectations()
    ' Arrange
    Dim foo = Mock.Create(Of FooBase)(Behavior.CallOriginal)

    Mock.Arrange(Function() foo.GetString("y")).Returns("z")

    ' Act
    Dim actualX = foo.GetString("x")
    Dim actualY = foo.GetString("y")

    Dim expectedX = "x"
    Dim expectedY = "z"

    ' Assert
    Assert.AreEqual(expectedX, actualX)
    Assert.AreEqual(expectedY, actualY)
End Sub
```

## See Also

* [Mock Behaviors](https://www.telerik.com/products/justmock/documentation/basic-usage/mock-behaviors/mock-behaviors)

* [RecursiveLoose](https://www.telerik.com/products/justmock/documentation/basic-usage/mock-behaviors/recursiveloose)

* [Strict](https://www.telerik.com/products/justmock/documentation/basic-usage/mock-behaviors/strict)
