-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Visual changes on device create (#480)
* Visual changes on general tab * Visual changes on LoRa tab + Fix missing UseOTAA property * Fixed missing image when selecting LoRa Model * Added unit tests * Fix alignment and useless "using"
- Loading branch information
1 parent
5f38e42
commit 7766068
Showing
5 changed files
with
317 additions
and
225 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/AzureIoTHub.Portal.Server.Tests.Unit/Validators/DeviceDetailValidatorTests.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,77 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Server.Tests.Unit.Validators | ||
{ | ||
using System; | ||
using AzureIoTHub.Portal.Client.Validators; | ||
using AzureIoTHub.Portal.Models.v10; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
internal class DeviceDetailsValidatorTests | ||
{ | ||
[Test] | ||
public void ValidateValidDevice() | ||
{ | ||
|
||
// Arrange | ||
var standardValidator = new DeviceDetailsValidator(); | ||
var device = new DeviceDetails() | ||
{ | ||
DeviceName = Guid.NewGuid().ToString(), | ||
ModelId = Guid.NewGuid().ToString(), | ||
DeviceID = Guid.NewGuid().ToString(), | ||
}; | ||
|
||
// Act | ||
var standardValidation = standardValidator.Validate(device); | ||
|
||
// Assert | ||
Assert.IsTrue(standardValidation.IsValid); | ||
Assert.AreEqual(0, standardValidation.Errors.Count); | ||
} | ||
|
||
[TestCase("DeviceName", "", "ModelIdValue", "DeviceIDValue")] | ||
[TestCase("ModelId", "DeviceNameValue", "", "DeviceIDValue")] | ||
[TestCase("DeviceID", "DeviceNameValue", "ModelIdValue", "")] | ||
public void ValidateMissingFieldShouldReturnError( | ||
string testedValue, | ||
string DeviceNameValue, | ||
string ModelIdValue, | ||
string DeviceIDValue) | ||
{ | ||
// Arrange | ||
var standardValidator = new DeviceDetailsValidator(); | ||
var device = new DeviceDetails() | ||
{ | ||
DeviceName = DeviceNameValue, | ||
ModelId =ModelIdValue, | ||
DeviceID = DeviceIDValue, | ||
}; | ||
|
||
// Act | ||
var standardValidation = standardValidator.Validate(device); | ||
|
||
// Assert | ||
Assert.IsFalse(standardValidation.IsValid); | ||
Assert.AreEqual(1, standardValidation.Errors.Count); | ||
Assert.AreEqual(standardValidation.Errors[0].ErrorMessage, $"{testedValue} is required."); | ||
} | ||
|
||
[Test] | ||
public void ValidateAllFieldsEmptyShouldReturnError() | ||
{ | ||
// Arrange | ||
var standardValidator = new DeviceDetailsValidator(); | ||
var device = new DeviceDetails(); | ||
|
||
// Act | ||
var standardValidation = standardValidator.Validate(device); | ||
|
||
// Assert | ||
Assert.IsFalse(standardValidation.IsValid); | ||
Assert.AreEqual(3, standardValidation.Errors.Count); | ||
} | ||
} | ||
} |
Oops, something went wrong.