- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added a few tests, fixed bugs that those tests turned up, and refactored a thew things on the way #25
Open
DarkStarDS9
wants to merge
19
commits into
ela-compil:v2
Choose a base branch
from
DarkStarDS9:Tests/Back2Back
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,473
−2,983
Open
added a few tests, fixed bugs that those tests turned up, and refactored a thew things on the way #25
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7201985
Added tests for more EventValues
DarkStarDS9 47b2b02
refactored ChangeOfValue
DarkStarDS9 926c122
Refactored ChangeOfState
DarkStarDS9 5d1306d
Added ASHRAE Examples F.1.2, F.1.3 and F.1.4
DarkStarDS9 abae73f
Added ASHRAE Examples F.1.5 and F.1.6
DarkStarDS9 f26bfac
Added ASHRAE Example F.1.8
DarkStarDS9 d85aa83
Added ASHRAE Examples F.1.9 to F.1.11
DarkStarDS9 80eeef5
Split Serialize.Services into smaller parts
DarkStarDS9 54abdb4
Added ASHRAE Examples F.2.1 and F.2.2
DarkStarDS9 92ed10a
Added ASHRAE Examples F.3.1 to F.3.8
DarkStarDS9 8d959c0
Started to move test-data to its own class so that it can be shared
DarkStarDS9 52669df
Added ASHRAE Examples F.3.9 and F.3.10
DarkStarDS9 42788cb
Added ASHRAE Examples F.4.1 to F.4.9
DarkStarDS9 6c1a779
added some back2back tests, fixed issues
DarkStarDS9 4113a78
covered AlarmAndEventServices
DarkStarDS9 550819d
covered FileAccessServices
DarkStarDS9 858fa06
covered ObjectAccessServices
DarkStarDS9 654fcad
covered RemoteDeviceManagementServices
DarkStarDS9 2073f10
added a single test for malformed packets
DarkStarDS9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactored ChangeOfState
commit 926c1223289a892e641cdbbf7d7fcef94a12837e
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
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 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
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 |
---|---|---|
@@ -1,10 +1,76 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO.BACnet.Base; | ||
using System.IO.BACnet.Helpers; | ||
using System.Reflection; | ||
|
||
namespace System.IO.BACnet.EventNotification.EventValues | ||
{ | ||
public class ChangeOfState : EventValuesBase | ||
public abstract class ChangeOfState : EventValuesBase, IHasStatusFlags | ||
{ | ||
public override BacnetEventTypes EventType => BacnetEventTypes.EVENT_CHANGE_OF_STATE; | ||
|
||
public BacnetPropertyState NewState { get; set; } | ||
public BacnetBitString StatusFlags { get; set; } | ||
} | ||
|
||
public class ChangeOfState<T> : ChangeOfState | ||
{ | ||
|
||
public T NewState { get; set; } | ||
|
||
protected ChangeOfState(T value) | ||
{ | ||
NewState = value; | ||
} | ||
|
||
public static ChangeOfState<bool> Create(bool value) | ||
=> new ChangeOfState<bool>(value); | ||
|
||
public static ChangeOfState<BacnetBinaryPv> Create(BacnetBinaryPv value) | ||
=> new ChangeOfState<BacnetBinaryPv>(value); | ||
|
||
public static ChangeOfState<BacnetEventTypes> Create(BacnetEventTypes value) | ||
=> new ChangeOfState<BacnetEventTypes>(value); | ||
|
||
public static ChangeOfState<BacnetPolarity> Create(BacnetPolarity value) | ||
=> new ChangeOfState<BacnetPolarity>(value); | ||
|
||
public static ChangeOfState<BacnetProgramRequest> Create(BacnetProgramRequest value) | ||
=> new ChangeOfState<BacnetProgramRequest>(value); | ||
|
||
public static ChangeOfState<BacnetProgramState> Create(BacnetProgramState value) | ||
=> new ChangeOfState<BacnetProgramState>(value); | ||
|
||
public static ChangeOfState<BacnetProgramError> Create(BacnetProgramError value) | ||
=> new ChangeOfState<BacnetProgramError>(value); | ||
|
||
public static ChangeOfState<BacnetReliability> Create(BacnetReliability value) | ||
=> new ChangeOfState<BacnetReliability>(value); | ||
|
||
public static ChangeOfState<BacnetEventStates> Create(BacnetEventStates value) | ||
=> new ChangeOfState<BacnetEventStates>(value); | ||
|
||
public static ChangeOfState<BacnetDeviceStatus> Create(BacnetDeviceStatus value) | ||
=> new ChangeOfState<BacnetDeviceStatus>(value); | ||
|
||
public static ChangeOfState<BacnetUnitsId> Create(BacnetUnitsId value) | ||
=> new ChangeOfState<BacnetUnitsId>(value); | ||
|
||
public static ChangeOfState<uint> Create(uint value) | ||
=> new ChangeOfState<uint>(value); | ||
|
||
public static ChangeOfState<BacnetLifeSafetyModes> Create(BacnetLifeSafetyModes value) | ||
=> new ChangeOfState<BacnetLifeSafetyModes>(value); | ||
|
||
public static ChangeOfState<BacnetLifeSafetyStates> Create(BacnetLifeSafetyStates value) | ||
=> new ChangeOfState<BacnetLifeSafetyStates>(value); | ||
} | ||
|
||
[ExcludeFromCodeCoverage] | ||
public abstract class ChangeOfStateFactory : ChangeOfState<object> | ||
{ | ||
protected ChangeOfStateFactory(object value) : base(value) | ||
{ | ||
throw new InvalidOperationException("this is a dummy class to avoid static call with generic type parameter"); | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System.IO.BACnet.EventNotification.EventValues; | ||
|
||
namespace System.IO.BACnet | ||
{ | ||
public interface IHasStatusFlags | ||
{ | ||
BacnetBitString StatusFlags { get; set; } | ||
} | ||
|
||
public static class Extensions | ||
{ | ||
public static T SetStatusFlags<T>(this T obj, BacnetBitString statusFlags) where T:IHasStatusFlags | ||
{ | ||
obj.StatusFlags = statusFlags; | ||
return obj; | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System.Reflection; | ||
|
||
namespace System.IO.BACnet.Helpers | ||
{ | ||
public static class FactoryHelper | ||
{ | ||
public static TReturn CreateReflected<TFactory, TReturn>(object value) where TReturn : class | ||
{ | ||
var mi = typeof(TFactory).GetMethod( | ||
"Create", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new[] { value.GetType() }, null); | ||
|
||
if (mi == null) | ||
throw new InvalidOperationException("factory method not found"); | ||
|
||
return mi.Invoke(null, new[] { value }) as TReturn; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other
DecodeEnumerate<>
method doesn't throw exception in case of -1. Shouldn't this be consistent?