| 1 |
// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later |
| 2 |
// Copyright (C) 2012 SIL International |
| 3 |
using System; |
| 4 |
using NUnit.Framework; |
| 5 |
using NGraphite; |
| 6 |
|
| 7 |
namespace NGraphiteTests |
| 8 |
{ |
| 9 |
[TestFixture()] |
| 10 |
public class FeatureRefTests |
| 11 |
{ |
| 12 |
Face _face; |
| 13 |
|
| 14 |
[SetUp] |
| 15 |
public void PerTestSetup() |
| 16 |
{ |
| 17 |
_face = new Face(TestConstants.PaduakFontLocation, FaceOptions.face_default); |
| 18 |
} |
| 19 |
|
| 20 |
[TearDown] |
| 21 |
public void PerTestTearDown() |
| 22 |
{ |
| 23 |
_face.Dispose(); |
| 24 |
} |
| 25 |
|
| 26 |
[Test()] |
| 27 |
public void FeatureValue_OnTestFeature_ReturnsZero() |
| 28 |
{ |
| 29 |
using(Featureval val = _face.FeaturevalForLang("en")) |
| 30 |
{ |
| 31 |
FeatureRef testFeature = CreateTestFeatureRef(); |
| 32 |
Assert.AreEqual(0, testFeature.FeatureValue(val)); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
[Test()] |
| 37 |
public void SetFeatureValue_SetValueInRange_ReturnsSuccessAndValueIsChanged() |
| 38 |
{ |
| 39 |
using(Featureval val = _face.FeaturevalForLang("en")) |
| 40 |
{ |
| 41 |
FeatureRef testFeature = CreateTestFeatureRef(); |
| 42 |
int ret = testFeature.SetFeatureValue(1, val); |
| 43 |
Assert.AreEqual(1, ret); |
| 44 |
Assert.AreEqual(1, testFeature.FeatureValue(val)); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
[Test()] |
| 49 |
public void Id_OnTestFeature_ReturnsExpectedId() |
| 50 |
{ |
| 51 |
Assert.AreEqual(1801744244, CreateTestFeatureRef().Id); |
| 52 |
} |
| 53 |
|
| 54 |
[Test()] |
| 55 |
public void NValues_OnTestFeature_ReturnsExpectedNumberOfValues() |
| 56 |
{ |
| 57 |
Assert.AreEqual(2, CreateTestFeatureRef().NValues()); |
| 58 |
} |
| 59 |
|
| 60 |
[Test()] |
| 61 |
public void Value_OnTestFeature_ReturnsExpectedValueAssociatedWithFeature() |
| 62 |
{ |
| 63 |
Assert.AreEqual(1, CreateTestFeatureRef().Value(1)); |
| 64 |
} |
| 65 |
|
| 66 |
[Test()] |
| 67 |
public void Label_asUtf8_ExpectedStringReturn() |
| 68 |
{ |
| 69 |
string label = CreateTestFeatureRef().Label("en", Encform.Utf8); |
| 70 |
Assert.AreEqual("Khamti style dots", label); |
| 71 |
} |
| 72 |
|
| 73 |
[Test()] |
| 74 |
public void Label_asUtf16_ExpectedStringReturn() |
| 75 |
{ |
| 76 |
string label = CreateTestFeatureRef().Label("en", Encform.Utf16); |
| 77 |
Assert.AreEqual("Khamti style dots", label); |
| 78 |
} |
| 79 |
|
| 80 |
[Test()] |
| 81 |
public void IdLabel() |
| 82 |
{ |
| 83 |
Assert.AreEqual("kdot", CreateTestFeatureRef().IdLabel); |
| 84 |
} |
| 85 |
|
| 86 |
[Test()] |
| 87 |
public void ValueLabel_OnTestFeature_ReturnsFalseString() |
| 88 |
{ |
| 89 |
Assert.AreEqual("False", CreateTestFeatureRef().ValueLabel(0, "en", Encform.Utf8)); |
| 90 |
} |
| 91 |
|
| 92 |
#region test helpers |
| 93 |
|
| 94 |
FeatureRef CreateTestFeatureRef() |
| 95 |
{ |
| 96 |
return _face.FindFref(1801744244); |
| 97 |
} |
| 98 |
|
| 99 |
#endregion |
| 100 |
} |
| 101 |
} |
| 102 |
|