public async Task InvalidAuthenticationTypeForEdgeDevice(string authTypeString) { // Arrange var authType = Enum.Parse <AuthenticationType>(authTypeString); var auth = new AuthenticationMechanismServiceModel() { AuthenticationType = authType, }; DeviceServiceModel model = new DeviceServiceModel( etag: "etag", id: "deviceId", c2DMessageCount: 0, lastActivity: DateTime.Now, connected: true, enabled: true, isEdgeDevice: true, lastStatusUpdated: DateTime.Now, twin: null, ioTHubHostName: this.ioTHubHostName, authentication: auth); // Act & Assert await Assert.ThrowsAsync <InvalidInputException>(async() => await this.devices.CreateAsync(model)); }
public async Task GetDeploymentImpactedDevicesTest(int numDevices) { // Arrange string deploymentId = "deploymentId"; var devices = new List <DeviceServiceModel>(); var auth = new AuthenticationMechanismServiceModel() { AuthenticationType = AuthenticationType.Sas, }; for (var i = 0; i < numDevices; i++) { devices.Add(new DeviceServiceModel( etag: "etag", id: "deviceId" + i, c2DMessageCount: 0, lastActivity: DateTime.Now, connected: true, enabled: true, isEdgeDevice: true, lastStatusUpdated: DateTime.Now, twin: null, ioTHubHostName: string.Empty, authentication: auth)); } this.deploymentsMock.Setup(x => x.GetDeployedDevicesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).ReturnsAsync( new DeviceServiceListModel(devices)); // Act var results = await this.controller.GetDeploymentImpactedDevices(deploymentId); // Assert Assert.Equal(numDevices, results.Items.Count); }
public DeviceServiceModel( string etag, string id, int c2DMessageCount, DateTime lastActivity, bool connected, bool enabled, bool isEdgeDevice, DateTime lastStatusUpdated, TwinServiceModel twin, AuthenticationMechanismServiceModel authentication, string ioTHubHostName) { this.Etag = etag; this.Id = id; this.C2DMessageCount = c2DMessageCount; this.LastActivity = lastActivity; this.Connected = connected; this.Enabled = enabled; this.IsEdgeDevice = isEdgeDevice; this.LastStatusUpdated = lastStatusUpdated; this.Twin = twin; this.IoTHubHostName = ioTHubHostName; this.Authentication = authentication; }
public AuthenticationMechanismApiModel(AuthenticationMechanismServiceModel model) { this.AuthenticationType = model.AuthenticationType; this.PrimaryKey = model.PrimaryKey; this.SecondaryKey = model.SecondaryKey; this.PrimaryThumbprint = model.PrimaryThumbprint; this.SecondaryThumbprint = model.SecondaryThumbprint; }