I\'m trying to write a unit test in C#.NET in the class below im formatting a me
ID: 3856400 • Letter: I
Question
I'm trying to write a unit test in C#.NET in the class below im formatting a message and im printing this message as showed below. im grouping the items in {} as shown. this class will get a message that has the {} attributes but in this class im inheriting from Comman class where im formatting the message the way I have showen below. Can you write a unit test that will test if I the message formatted in CopyDocumentHistory class will match the unit test format. kinda like Assert.AreEqual()?
namespace Historian.Commands {
public class CopyDocumentHistory : Command { //Command is an abstract class contains properties: ClientUserName, ClientAppId, SourceLoanNumber, DetinationLoanNumber
public override string FormattedText() { //method to format a message returning a string
return $"Copied by {ClientUserName} using application {ClientAppId} from loan {SourceLoanNumber} to loan {DestinationLoanNumber}"; //the formatted message
}
}
}
Explanation / Answer
namespace Historian.Commands {
public class CopyDocumentHistory : Command { //Command is an abstract class contains properties: ClientUserName, ClientAppId, SourceLoanNumber, DetinationLoanNumber
public override string FormattedText() { //method to format a message returning a string
return $"Copied by {ClientUserName} using application {ClientAppId} from loan {SourceLoanNumber} to loan {DestinationLoanNumber}"; //the formatted message
}
}
}