-
Notifications
You must be signed in to change notification settings - Fork 1
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 #15 from JonasMH/develop
Develop
- Loading branch information
Showing
12 changed files
with
173 additions
and
47 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
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
66 changes: 66 additions & 0 deletions
66
test/ToMqttNet.Test.Unit/MqttDefaultLightDiscoveryConfigTests.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,66 @@ | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ToMqttNet.Test.Unit | ||
{ | ||
|
||
public class MqttDefaultLightDiscoveryConfigTests | ||
{ | ||
[Fact] | ||
public void ToJson_SchemaIsBasic() | ||
{ | ||
// Arrange | ||
var sut = new MqttDefaultLightDiscoveryConfig() | ||
{ | ||
|
||
}; | ||
|
||
// Act | ||
var result = (JObject)JsonConvert.DeserializeObject(sut.ToJson())!; | ||
|
||
// Assert | ||
Assert.Equal("basic", result["schema"]!.ToString()); | ||
// The documentation says it should be null or default - but in reality setting this to default makes it fail, so we just force it to basic | ||
} | ||
|
||
[Fact] | ||
public void ToJson_PayloadCanBeBoolean() | ||
{ | ||
// Arrange | ||
var sut = new MqttDefaultLightDiscoveryConfig() | ||
{ | ||
PayloadOn = true | ||
}; | ||
|
||
// Act | ||
var result = (JObject)JsonConvert.DeserializeObject(sut.ToJson())!; | ||
|
||
// Assert | ||
Assert.True(result["payload_on"]!.Value<bool>()); | ||
// The documentation says it should be null or default - but in reality setting this to default makes it fail, so we just force it to basic | ||
} | ||
|
||
[Fact] | ||
public void ToJson_PayloadCanBeString() | ||
{ | ||
// Arrange | ||
var sut = new MqttDefaultLightDiscoveryConfig() | ||
{ | ||
PayloadOn = "someString" | ||
}; | ||
|
||
// Act | ||
var result = (JObject)JsonConvert.DeserializeObject(sut.ToJson())!; | ||
|
||
// Assert | ||
Assert.Equal("someString", result["payload_on"]!.Value<string>()); | ||
// The documentation says it should be null or default - but in reality setting this to default makes it fail, so we just force it to basic | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/ToMqttNet.Test.Unit/MqttJsonLightDiscoveryConfigTests.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,25 @@ | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json; | ||
using Xunit; | ||
|
||
namespace ToMqttNet.Test.Unit | ||
{ | ||
public class MqttJsonLightDiscoveryConfigTests | ||
{ | ||
[Fact] | ||
public void ToJson_SchemaIsBasic() | ||
{ | ||
// Arrange | ||
var sut = new MqttJsonLightDiscoveryConfig() | ||
{ | ||
|
||
}; | ||
|
||
// Act | ||
var result = (JObject)JsonConvert.DeserializeObject(sut.ToJson())!; | ||
|
||
// Assert | ||
Assert.Equal("json", result["schema"]!.ToString()); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/ToMqttNet.Test.Unit/MqttTemplateLightDiscoveryConfigTests.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,25 @@ | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json; | ||
using Xunit; | ||
|
||
namespace ToMqttNet.Test.Unit | ||
{ | ||
public class MqttTemplateLightDiscoveryConfigTests | ||
{ | ||
[Fact] | ||
public void ToJson_SchemaIsBasic() | ||
{ | ||
// Arrange | ||
var sut = new MqttTemplateLightDiscoveryConfig() | ||
{ | ||
|
||
}; | ||
|
||
// Act | ||
var result = (JObject)JsonConvert.DeserializeObject(sut.ToJson())!; | ||
|
||
// Assert | ||
Assert.Equal("template", result["schema"]!.ToString()); | ||
} | ||
} | ||
} |
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