Implemented MR feedback

This commit is contained in:
CoudronJerome
2023-03-28 15:37:17 +02:00
parent dfdb2ab10b
commit be8885a508
6 changed files with 47 additions and 39 deletions

View File

@@ -26,7 +26,7 @@ public class ModelListTest
{
ModelIndex value = (ModelIndex)field.GetValue(null);
string name = field.Name;
ModelTuple model = new ModelTuple();
ModelList.ModelTuple model = new ModelList.ModelTuple();
// This is all we will need to distinguish
model.index = value;
@@ -36,11 +36,23 @@ public class ModelListTest
}
}
public void TestGetCurrentModel()
{
System.Random random = new System.Random();
ModelIndex value = (ModelIndex)random.Next(modelList.models.Count);
modelList.SetCurrentModel(value);
Assert.AreEqual(value, modelList.GetCurrentModel().index);
// Check if empty model fails gracefully (returns null)
Assert.IsNull(ScriptableObject.CreateInstance<ModelList>().GetCurrentModel());
}
/// <summary>
/// Check if all courses can be correctly gotten and set as current via SetCurrentCourse
/// Check if all models can be correctly set as current via SetCurrentModel
/// </summary>
[Test]
public void TestGetSetCurrentModel()
public void TestSetCurrentModel()
{
foreach (var field in typeof(ModelIndex).GetFields())
{
@@ -50,12 +62,16 @@ public class ModelListTest
string name = field.Name;
modelList.SetCurrentModel(value);
// Fetch the current course and check if its name is the same as the one we made into the current one
ModelTuple m = modelList.models[modelList.currentModelIndex];
// Fetch the current model and check if its name is the same as the one we made into the current one
ModelList.ModelTuple m = modelList.models[modelList.currentModelIndex];
Assert.AreEqual(m.index, value);
Assert.IsTrue(m.model is NNModel || m.model is null);
}
}
ModelList emptyList = ScriptableObject.CreateInstance<ModelList>();
emptyList.SetCurrentModel(ModelIndex.FINGERSPELLING);
Assert.IsTrue(emptyList.currentModelIndex == -1);
}
}