/** * Sets up sequence for DeviceGroupsClient.GetDeviceGroupsAsync * that will return groups with different etags */ private void SetupSequenceForDeviceGroupsClientMock() { this.deviceGroupsClientMock.SetupSequence(x => x.GetDeviceGroupsAsync()) .Returns(Task.FromResult(TestHelperFunctions.CreateDeviceGroupListApiModel("etag1", "group1"))) .Returns(Task.FromResult(TestHelperFunctions.CreateDeviceGroupListApiModel("etag2", "group1"))) .Returns(Task.FromResult(TestHelperFunctions.CreateDeviceGroupListApiModel("etag3", "group1"))); }
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 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); }
// Set up device group client to return dummy device group list that will not change private void SetupDeviceGroupsClientMock() { this.deviceGroupListApiModel = TestHelperFunctions.CreateDeviceGroupListApiModel("etag1", "groupid"); this.deviceGroupsClientMock.Setup(x => x.GetDeviceGroupsAsync()).Returns(Task.FromResult(this.deviceGroupListApiModel)); }
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); }