Skip to main content
added 275 characters in body
Source Link
anonygoose
  • 736
  • 3
  • 10

How I'm reading it, they confusingly refer to 2 different bits of code as GetById here.

In the first instance they're referring to this method on the ShoppingCartController:

public ActionResult<ShoppingItem> Get(Guid id)

This is the method that they are unit testing.

In the second instance they're referring to a piece of code that isn't currently under test, this method on the IShoppingCartService

ShoppingItem GetById(Guid id);

As Niels says, this method on the IShoppingCartService is mocked/faked because it's outside the scope of a unit test.

I think the confusion when reading this page comes from the subheading "Testing the GetById method". What they really appear to mean is "Testing the Get(Guid) method". As you mention, there would be no point in testing the GetById method from the service as it is fake.

How I'm reading it, they confusingly refer to 2 different bits of code as GetById here.

In the first instance they're referring to this method on the ShoppingCartController:

public ActionResult<ShoppingItem> Get(Guid id)

This is the method that they are unit testing.

In the second instance they're referring to a piece of code that isn't currently under test, this method on the IShoppingCartService

ShoppingItem GetById(Guid id);

As Niels says, this method on the IShoppingCartService is mocked/faked because it's outside the scope of a unit test.

How I'm reading it, they confusingly refer to 2 different bits of code as GetById here.

In the first instance they're referring to this method on the ShoppingCartController:

public ActionResult<ShoppingItem> Get(Guid id)

This is the method that they are unit testing.

In the second instance they're referring to a piece of code that isn't currently under test, this method on the IShoppingCartService

ShoppingItem GetById(Guid id);

As Niels says, this method on the IShoppingCartService is mocked/faked because it's outside the scope of a unit test.

I think the confusion when reading this page comes from the subheading "Testing the GetById method". What they really appear to mean is "Testing the Get(Guid) method". As you mention, there would be no point in testing the GetById method from the service as it is fake.

Source Link
anonygoose
  • 736
  • 3
  • 10

How I'm reading it, they confusingly refer to 2 different bits of code as GetById here.

In the first instance they're referring to this method on the ShoppingCartController:

public ActionResult<ShoppingItem> Get(Guid id)

This is the method that they are unit testing.

In the second instance they're referring to a piece of code that isn't currently under test, this method on the IShoppingCartService

ShoppingItem GetById(Guid id);

As Niels says, this method on the IShoppingCartService is mocked/faked because it's outside the scope of a unit test.