I have a function like,
public void UpdateData()
{
Data data = GetDataFromDatabase()
if(!data.IsDefault)
{
// Do some change in data object
SaveData(data);
}
}
I want write unit test for SaveData(Data data) function,
public bool SaveData(Data data)
{
// Code for saving data in database
}
Above function contains code for saving data in database and there are no validations. Validations are done before calling this function.
Applications requirement is default data should not be updated. So while writing unit test should I consider this requirement?
If I write Unit Test like,
public void SaveData_DefaultData()
{
SaveData(defaultData);
Assert.IsTrue(); // Some condition in assert to check whether the default data is updated.
}
By looking at the SaveData function I know that this test case is going to fail. So my question is do I need to consider this test case?
default datahere? Can you share the code ofSaveDatamethod? What is the logic in the method which does not update thedefault data?saves/updates data in database nothing elsecan you share this code? You are trying to unit test the code ofSaveDatamethod?