public void VerifyGetGroupToDeviceMappingFailsAfter5Retries() { // Arrange this.SetupAllExceptionSequenceDevicesClientMock(); // Act Exception ex = Assert.Throws <AggregateException>(() => this.deviceGroupsClient.GetGroupToDevicesMappingAsync(TestHelperFunctions.CreateDeviceGroupListApiModel("etag", GROUP_ID)).Wait()); // Assert Assert.IsType <ExternalDependencyException>(ex.InnerException); TestHelperFunctions.VerifyWarningsLogged(this.logMock, 5); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 1); }
public void VerifyGetGroupToDeviceMappingRetriesOnException() { // Arrange this.Setup4ExceptionSequenceDevicesClientMock(); // Act Dictionary <string, IEnumerable <string> > mapping = this.deviceGroupsClient.GetGroupToDevicesMappingAsync(TestHelperFunctions.CreateDeviceGroupListApiModel("etag", GROUP_ID)).Result; // Assert Assert.True(mapping.ContainsKey(GROUP_ID)); Assert.Equal(3, mapping[GROUP_ID].Count()); TestHelperFunctions.VerifyWarningsLogged(this.logMock, 4); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); }
public void ReferenceDataWrittenWithEmptyMapping() { // Arrange Dictionary <string, IEnumerable <string> > deviceMapping = new Dictionary <string, IEnumerable <string> >(); // Act this.deviceGroupsWriter.ExportMapToReferenceDataAsync(deviceMapping, this.timestamp); // Assert this.VerifyFileWrapperMethods(deviceMapping); this.VerifyCloudStorageWrapperMethods(); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); }
public void VerifyGetGroupToDeviceMappingEmptyList() { // Arrange this.SetUpDevicesClientMockEmptyList(); // Act Dictionary <string, IEnumerable <string> > mapping = this.deviceGroupsClient.GetGroupToDevicesMappingAsync(TestHelperFunctions.CreateDeviceGroupListApiModel("etag", GROUP_ID)).Result; // Assert Assert.Empty(mapping.Keys); TestHelperFunctions.VerifyWarningsLogged(this.logMock, 0); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); }
public void VerifyDeviceEventProcessorUpdatesEventHubStatus() { // Arrange IEventHubStatus eventHubStatus = new EventHubStatus(); DeviceEventProcessor deviceEventProcessor = new DeviceEventProcessor(eventHubStatus, 60000, this.logMock.Object); EventData data = new EventData(new byte[0]); List <EventData> eventDataList = new List <EventData> { data }; // Act deviceEventProcessor.ProcessEventsAsync(null, eventDataList).Wait(TEST_TIMEOUT_MS); // Assert Assert.True(eventHubStatus.SeenChanges); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); }
public void BasicReferenceDataIsWritten() { // Arrange var deviceMapping = new Dictionary <string, IEnumerable <string> > { ["group1"] = new[] { "device1", "device2", "device3" }, ["group2"] = new[] { "device6", "device4", "device5" } }; // Act this.deviceGroupsWriter.ExportMapToReferenceDataAsync(deviceMapping, this.timestamp); // Assert this.VerifyFileWrapperMethods(deviceMapping); this.VerifyCloudStorageWrapperMethods(); TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); }
/** * Verifies agent functionality, where agent ran "loops" times * and is expected to write to blob storage "expectedWrites" times * Verifies event hub processor is set up, and expected loops and * writes occur. */ private void VerifyEndToEndResults(int loops, int expectedWrites) { TestHelperFunctions.VerifyErrorsLogged(this.logMock, 0); this.eventProcessorHostWrapperMock.Verify(e => e.CreateEventProcessorHost( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once()); this.eventProcessorHostWrapperMock.Verify(e => e.RegisterEventProcessorFactoryAsync( It.IsAny <EventProcessorHost>(), this.eventProcessorFactory), Times.Once()); this.deviceGroupsClientMock.Verify(d => d.GetDeviceGroupsAsync(), Times.Exactly(loops)); this.deviceGroupsWriterMock.Verify(d => d.ExportMapToReferenceDataAsync( It.IsAny <Dictionary <string, IEnumerable <string> > >(), It.IsAny <DateTimeOffset>()), Times.Exactly(expectedWrites)); }