So a quick rundown about the program I am testing. The program is a small app that register athletes' track records from all kinds of track meet. Right now I am testing the functionality of the option to create a new meet "CreateMeet". Every meet have different type of events: track, javelin, etc... and it takes place at specific time and location.
I wrote a small test function that allows me to test the creation of a new meet into the database, and so far the test failed because according to the test results, the problem is in my Assert function. I was sure that it would work but I guess it didn't. The test failure error gives me this:
Test Failed - CreateMeet
Message: Assert.IsTrue failed.
Below is the test function:
public void CreateMeet()
{
var createMeet = new Meet()
{
MeetId = 1234,
MeetName = Spring Meet,
MeetDate = DateTime.Now,
MeetLocation = "Paris, France",
MeasurementType = "Metric"
};
var MeetController = new MeetsController();
MeetController.AddMeet(createMeet);
var testList = new List<Meet>(MeetController.RetrieveAllMeets());
Assert.IsTrue(testList.Contains(createMeet));
}
Which Assert or which type of function do you guys think I may need for this function to generate a successful test? I'm stumped on any other options. Your input is appreciated.
UPDATE Additional code as per D-Shih's request.
public IList<Meet> RetrieveAllMeets()
{
JObject jsonMeetObj = JObject.Parse(FieldScribeAPIRequests.FieldScribeGETAsync(FieldScribeAPIRequests.FieldScribeAPIRootAddress + "meets"));
IList<JToken> results = jsonMeetObj["value"].Children().ToList();
IList<Meet> meets = new List<Meet>();
foreach (JToken item in results)
meets.Add(item.ToObject<Meet>());
return meets;
}
MeetController.RetrieveAllMeets()?