I copy a unit test in c#. However an error is found.

BenTam 1,561 Reputation points
2021-12-26T09:50:05.33+00:00

Dear All,

I copy a unit test in c# from YouTube (https://www.youtube.com/watch?v=HYrXogLj7vg). See the screen captures. Could anybody tell me how to fix it?

160476-unittest.gif

160417-unittest2.gif

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,266 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sreeju Nair 11,611 Reputation points
    2021-12-26T10:29:51.037+00:00

    Based on your explanation, you are getting your build failed. For the following code,

    var result=reservation.CanBeCancelledBy(new User{IsAdmin});

    we can see the IsAdmin is the property of the User object, so when you define the new object, you need to assign a value to it. Try the following

    var result=reservation.CanBeCancelledBy(new User{IsAdmin=true});

    You may adjust the IsAdmin assignment based on your business requirement.

    Hope this helps

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful