-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from hbjorgo/feature/tests
- Loading branch information
Showing
54 changed files
with
577 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/HeboTech.ATLib.Tests/CodingSchemes/CharacterSetHelpersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using System; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class CharacterSetHelpersTests | ||
{ | ||
[Theory] | ||
[InlineData("GSM", CharacterSet.Gsm7)] | ||
[InlineData("UCS2", CharacterSet.UCS2)] | ||
public void FromString_returns_correct_string(string value, CharacterSet expectedCharacterSet) | ||
{ | ||
Assert.Equal(expectedCharacterSet, CharacterSetHelpers.FromString(value)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("InvalidCharacterSet")] | ||
public void FromString_throws_on_unknown_characterset(string value) | ||
{ | ||
Assert.Throws<ArgumentException>(() => CharacterSetHelpers.FromString(value)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(CharacterSet.Gsm7, "GSM")] | ||
[InlineData(CharacterSet.UCS2, "UCS2")] | ||
public void ToString_returns_correct_string(CharacterSet characterSet, string expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, CharacterSetHelpers.ToString(characterSet)); | ||
} | ||
|
||
[Theory] | ||
[InlineData((CharacterSet)255)] | ||
public void ToString_throws_on_unknown_characterset(CharacterSet characterSet) | ||
{ | ||
Assert.Throws<ArgumentException>(() => CharacterSetHelpers.ToString(characterSet)); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/HeboTech.ATLib.Tests/CodingSchemes/CharacterSetTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class CharacterSetTests | ||
{ | ||
[Theory] | ||
[InlineData(CharacterSet.Gsm7, 0x00)] | ||
[InlineData(CharacterSet.UCS2, 0x08)] | ||
public void Has_correct_values(CharacterSet characterSet, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)characterSet); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/HeboTech.ATLib.Tests/CodingSchemes/CodingGroupTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class CodingGroupTests | ||
{ | ||
[Theory] | ||
[InlineData(CodingGroup.GeneralDataCoding, 0)] | ||
[InlineData(CodingGroup.MessageMarkedForAutomaticDeletion, 1)] | ||
[InlineData(CodingGroup.Reserved, 2)] | ||
[InlineData(CodingGroup.MessageWaitingInfo_DiscardMessage, 3)] | ||
[InlineData(CodingGroup.MessageWaitingInfo_StoreMessage, 4)] | ||
[InlineData(CodingGroup.DataCoding_MessageClass, 5)] | ||
internal void Has_correct_values(CodingGroup codingGroup, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)codingGroup); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/HeboTech.ATLib.Tests/CodingSchemes/DataCodingSchemeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using System; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class DataCodingSchemeTests | ||
{ | ||
[Theory] | ||
[InlineData(0x00, CharacterSet.Gsm7, MessageClass.Default, CodingGroup.GeneralDataCoding)] | ||
[InlineData(0x08, CharacterSet.UCS2, MessageClass.Default, CodingGroup.GeneralDataCoding)] | ||
[InlineData(0x11, CharacterSet.Gsm7, MessageClass.Class1, CodingGroup.GeneralDataCoding)] | ||
internal void ParseByte_returns_correct_DataCodingScheme(byte value, CharacterSet expectedCharacterSet, MessageClass expectedMessageClass, CodingGroup expectedCodingGroup) | ||
{ | ||
var dcs = DataCodingScheme.ParseByte(value); | ||
|
||
Assert.Equal(expectedCharacterSet, dcs.CharacterSet); | ||
Assert.Equal(expectedMessageClass, dcs.MessageClass); | ||
Assert.Equal(expectedCodingGroup, dcs.CodingGroup); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0x01)] | ||
[InlineData(0xFF)] | ||
internal void ParseByte_throws_on_unknown_value(byte value) | ||
{ | ||
Assert.Throws<ArgumentException>(() => DataCodingScheme.ParseByte(value)); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/HeboTech.ATLib.Tests/CodingSchemes/Gsm7ExtensionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class Gsm7ExtensionTests | ||
{ | ||
[Theory] | ||
[InlineData(Gsm7Extension.Default, 0x00)] | ||
[InlineData(Gsm7Extension.Turkish, 0x01)] | ||
[InlineData(Gsm7Extension.Spanish, 0x02)] | ||
[InlineData(Gsm7Extension.Portugese, 0x03)] | ||
[InlineData(Gsm7Extension.BengaliAndAssamese, 0x04)] | ||
[InlineData(Gsm7Extension.Gujarati, 0x05)] | ||
[InlineData(Gsm7Extension.Hindi, 0x06)] | ||
[InlineData(Gsm7Extension.Kannada, 0x07)] | ||
[InlineData(Gsm7Extension.Malayalam, 0x08)] | ||
[InlineData(Gsm7Extension.Oriya, 0x09)] | ||
[InlineData(Gsm7Extension.Punjabi, 0x0A)] | ||
[InlineData(Gsm7Extension.Tamil, 0x0B)] | ||
[InlineData(Gsm7Extension.Telugu, 0x0C)] | ||
[InlineData(Gsm7Extension.Urdu, 0x0D)] | ||
internal void Has_correct_values(Gsm7Extension gsm7Extension, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)gsm7Extension); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/HeboTech.ATLib.Tests/CodingSchemes/MessageClassTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using HeboTech.ATLib.CodingSchemes; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.CodingSchemes | ||
{ | ||
public class MessageClassTests | ||
{ | ||
[Theory] | ||
[InlineData(MessageClass.Default, 0x00)] | ||
[InlineData(MessageClass.Class0, 0x01)] | ||
[InlineData(MessageClass.Class1, 0x02)] | ||
[InlineData(MessageClass.Class2, 0x03)] | ||
[InlineData(MessageClass.Class3, 0x04)] | ||
internal void Has_correct_values(MessageClass messageClass, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)messageClass); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using HeboTech.ATLib.Extensions; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class BatteryChargeStatusTests | ||
{ | ||
[Theory] | ||
[InlineData(BatteryChargeStatus.PoweredByBattery, 0)] | ||
[InlineData(BatteryChargeStatus.Charging, 1)] | ||
[InlineData(BatteryChargeStatus.ChargingFinished, 2)] | ||
[InlineData(BatteryChargeStatus.PowerFault, 3)] | ||
internal void Has_correct_values(BatteryChargeStatus batteryChargeStatus, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)batteryChargeStatus); | ||
} | ||
|
||
[Theory] | ||
[InlineData(BatteryChargeStatus.PoweredByBattery, "Powered by battery")] | ||
[InlineData(BatteryChargeStatus.Charging, "Charging")] | ||
[InlineData(BatteryChargeStatus.ChargingFinished, "Charging finished")] | ||
[InlineData(BatteryChargeStatus.PowerFault, "Power fault")] | ||
internal void Has_correct_descriptions(BatteryChargeStatus batteryChargeStatus, string expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, batteryChargeStatus.GetDescription()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using UnitsNet; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class BatteryStatusTests | ||
{ | ||
[Fact] | ||
internal void Sets_properties() | ||
{ | ||
BatteryStatus sut = new(BatteryChargeStatus.Charging, Ratio.FromPercent(69)); | ||
|
||
Assert.Equal(BatteryChargeStatus.Charging, sut.Status); | ||
Assert.Equal(Ratio.FromPercent(69), sut.ChargeLevel); | ||
Assert.Null(sut.Voltage); | ||
} | ||
|
||
[Fact] | ||
internal void Sets_properties_including_voltage() | ||
{ | ||
BatteryStatus sut = new(BatteryChargeStatus.Charging, Ratio.FromPercent(69), ElectricPotential.FromVolts(2.7)); | ||
|
||
Assert.Equal(BatteryChargeStatus.Charging, sut.Status); | ||
Assert.Equal(Ratio.FromPercent(69), sut.ChargeLevel); | ||
Assert.Equal(ElectricPotential.FromVolts(2.7), sut.Voltage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using System; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class CallDetailsTests | ||
{ | ||
[Fact] | ||
internal void Sets_properties() | ||
{ | ||
CallDetails sut = new(TimeSpan.FromMinutes(7)); | ||
|
||
Assert.Equal(TimeSpan.FromMinutes(7), sut.Duration); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class ImsiTests | ||
{ | ||
[Fact] | ||
public void Sets_properties() | ||
{ | ||
Imsi sut = new("123451234512345"); | ||
|
||
Assert.Equal("123451234512345", sut.Value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using HeboTech.ATLib.Dtos; | ||
using System; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class MessageStorageTests | ||
{ | ||
[Theory] | ||
[InlineData("SM")] | ||
[InlineData("ME")] | ||
[InlineData("MT")] | ||
[InlineData("BM")] | ||
[InlineData("SR")] | ||
[InlineData("TA")] | ||
public void TProperties_are_set(string storageName) | ||
{ | ||
MessageStorage storage = MessageStorage.Parse(storageName); | ||
|
||
Assert.Equal(storageName, storage.Value); | ||
Assert.Equal(storageName, storage); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("")] | ||
[InlineData("A")] | ||
[InlineData("AB")] | ||
public void Throws_on_invalid_name(string storageName) | ||
{ | ||
Assert.Throws<ArgumentException>(() => MessageStorage.Parse(storageName)); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/HeboTech.ATLib.Tests/DTOs/NumberPlanIdentificationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class NumberplanIdentificationTests | ||
{ | ||
[Theory] | ||
[InlineData(NumberPlanIdentification.Unknown, 0x00)] | ||
[InlineData(NumberPlanIdentification.ISDN, 0x01)] | ||
[InlineData(NumberPlanIdentification.DataNumbering, 0x03)] | ||
[InlineData(NumberPlanIdentification.Telex, 0x04)] | ||
[InlineData(NumberPlanIdentification.ServiceCentreSpecific1, 0x05)] | ||
[InlineData(NumberPlanIdentification.ServiceCentreSpecific2, 0x06)] | ||
[InlineData(NumberPlanIdentification.NationalNumbering, 0x08)] | ||
[InlineData(NumberPlanIdentification.PrivateNumbering, 0x09)] | ||
[InlineData(NumberPlanIdentification.ErmesNumbering, 0x0A)] | ||
[InlineData(NumberPlanIdentification.ReservedForExtension, 0x0F)] | ||
internal void Has_correct_values(NumberPlanIdentification numberplanIdentification, int expectedValue) | ||
{ | ||
Assert.Equal(expectedValue, (int)numberplanIdentification); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/HeboTech.ATLib.Tests/DTOs/PersonalIdentificationNumberTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using HeboTech.ATLib.DTOs; | ||
using System; | ||
using Xunit; | ||
|
||
namespace HeboTech.ATLib.Tests.DTOs | ||
{ | ||
public class PersonalIdentificationNumberTests | ||
{ | ||
[Fact] | ||
internal void Sets_properties() | ||
{ | ||
PersonalIdentificationNumber sut = new("1234"); | ||
|
||
Assert.Equal("1234", sut.Pin); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("")] | ||
[InlineData(" ")] | ||
[InlineData(" ")] | ||
[InlineData("12345")] | ||
[InlineData("A123")] | ||
[InlineData("ABCD")] | ||
internal void Invalid_pin_throws(string pin) | ||
{ | ||
Assert.Throws<ArgumentException>(() => new PersonalIdentificationNumber(pin)); | ||
} | ||
} | ||
} |
Oops, something went wrong.