-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2 from jmayer913/v1.1.0/VersionBranch
V1.1.0/version branch
- Loading branch information
Showing
15 changed files
with
754 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 System.Diagnostics.CodeAnalysis; | ||
|
||
namespace JMayer.Example.WindowsService.BSM; | ||
|
||
/// <summary> | ||
/// The class manages comparing two BSM objects. | ||
/// </summary> | ||
public class BSMEqualityComparer : IEqualityComparer<BSM> | ||
{ | ||
/// <inheritdoc/> | ||
public bool Equals(BSM? x, BSM? y) | ||
{ | ||
if (x == null || y == null) | ||
{ | ||
return false; | ||
} | ||
|
||
return new BaggageTagDetailEqualityComparer().Equals(x.BaggageTagDetails, y.BaggageTagDetails) | ||
&& x.ChangeOfStatus == y.ChangeOfStatus | ||
&& new OutboundFlightEqualityComparer().Equals(x.OutboundFlight, y.OutboundFlight) | ||
&& new PassengerNameEqualityComparer().Equals(x.PassengerName, y.PassengerName) | ||
&& new VersionSupplementaryDataEqualityComparer().Equals(x.VersionSupplementaryData, y.VersionSupplementaryData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public int GetHashCode([DisallowNull] BSM obj) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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
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
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
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
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
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
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,154 @@ | ||
using JMayer.Example.WindowsService.BSM; | ||
|
||
namespace TestProject.Test; | ||
|
||
/// <summary> | ||
/// The class manages testing the BSM equality comparer. | ||
/// </summary> | ||
public class BSMEqualityComparerUnitTest | ||
{ | ||
/// <summary> | ||
/// The constant for the .F airline. | ||
/// </summary> | ||
private const string DotFAirline = "AA"; | ||
|
||
/// <summary> | ||
/// The constant for the .F class of travel. | ||
/// </summary> | ||
private const string DotFClassOfTravel = "A"; | ||
|
||
/// <summary> | ||
/// The constant for the .F destination. | ||
/// </summary> | ||
private const string DotFDestination = "MSY"; | ||
|
||
/// <summary> | ||
/// The constant for the .F flight number. | ||
/// </summary> | ||
private const string DotFFlightNumber = "1234"; | ||
|
||
/// <summary> | ||
/// The constant for the .N tag number. | ||
/// </summary> | ||
private const string DotNTagNumber = "0001123456"; | ||
|
||
/// <summary> | ||
/// The constant for the .P given name. | ||
/// </summary> | ||
private const string DotPGivenName = "PASSENGER"; | ||
|
||
/// <summary> | ||
/// The constant for the .P surname. | ||
/// </summary> | ||
private const string DotPSurName = "TEST"; | ||
|
||
/// <summary> | ||
/// The constant for the .V airport code. | ||
/// </summary> | ||
private const string DotVAirportCode = "MCO"; | ||
|
||
/// <summary> | ||
/// The constant for the .V data dictionary version number. | ||
/// </summary> | ||
private const int DotVDataDictionaryVersionNumber = 1; | ||
|
||
/// <summary> | ||
/// The method verifies equality failure when the ChangeOfStatus property is different between the two objects. | ||
/// </summary> | ||
[Fact] | ||
public void VerifyFailureChangeOfStatus() | ||
{ | ||
BSM bsm1 = new() | ||
{ | ||
ChangeOfStatus = BSM.Add, | ||
}; | ||
BSM bsm2 = new() | ||
{ | ||
ChangeOfStatus = BSM.Change, | ||
}; | ||
|
||
Assert.False(new BSMEqualityComparer().Equals(bsm1, bsm2)); | ||
} | ||
|
||
/// <summary> | ||
/// The method verifies equality failure when two nulls are compared. | ||
/// </summary> | ||
[Fact] | ||
public void VerifyFailureBothNull() => Assert.False(new BSMEqualityComparer().Equals(null, null)); | ||
|
||
/// <summary> | ||
/// The method verifies equality failure when an object and null are compared. | ||
/// </summary> | ||
[Fact] | ||
public void VerifyFailureOneIsNull() | ||
{ | ||
BSM bsm = new() | ||
{ | ||
BaggageTagDetails = new BaggageTagDetails() | ||
{ | ||
BaggageTagNumbers = [DotNTagNumber], | ||
}, | ||
ChangeOfStatus = BSM.Add, | ||
OutboundFlight = new OutboundFlight() | ||
{ | ||
Airline = DotFAirline, | ||
ClassOfTravel = DotFClassOfTravel, | ||
Destination = DotFDestination, | ||
FlightDate = DateTime.Today.ToDayMonthFormat(), | ||
FlightNumber = DotFFlightNumber, | ||
}, | ||
PassengerName = new PassengerName() | ||
{ | ||
GivenNames = [DotPGivenName], | ||
SurName = DotPSurName, | ||
}, | ||
VersionSupplementaryData = new() | ||
{ | ||
AirportCode = DotVAirportCode, | ||
BaggageSourceIndicator = VersionSupplementaryData.LocalBaggageSourceIndicator, | ||
DataDictionaryVersionNumber = DotVDataDictionaryVersionNumber, | ||
}, | ||
}; | ||
|
||
Assert.False(new BSMEqualityComparer().Equals(bsm, null)); | ||
Assert.False(new BSMEqualityComparer().Equals(null, bsm)); | ||
} | ||
|
||
/// <summary> | ||
/// The method verifies equality failure when an object and null are compared. | ||
/// </summary> | ||
[Fact] | ||
public void VerifySuccess() | ||
{ | ||
BSM bsm1 = new() | ||
{ | ||
BaggageTagDetails = new BaggageTagDetails() | ||
{ | ||
BaggageTagNumbers = [DotNTagNumber], | ||
}, | ||
ChangeOfStatus = BSM.Add, | ||
OutboundFlight = new OutboundFlight() | ||
{ | ||
Airline = DotFAirline, | ||
ClassOfTravel = DotFClassOfTravel, | ||
Destination = DotFDestination, | ||
FlightDate = DateTime.Today.ToDayMonthFormat(), | ||
FlightNumber = DotFFlightNumber, | ||
}, | ||
PassengerName = new PassengerName() | ||
{ | ||
GivenNames = [DotPGivenName], | ||
SurName = DotPSurName, | ||
}, | ||
VersionSupplementaryData = new() | ||
{ | ||
AirportCode = DotVAirportCode, | ||
BaggageSourceIndicator = VersionSupplementaryData.LocalBaggageSourceIndicator, | ||
DataDictionaryVersionNumber = DotVDataDictionaryVersionNumber, | ||
}, | ||
}; | ||
BSM bsm2 = new(bsm1); | ||
|
||
Assert.True(new BSMEqualityComparer().Equals(bsm1, bsm2)); | ||
} | ||
} |
Oops, something went wrong.