示例#1
0
 /**
  * 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")));
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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));
        }
示例#9
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 IEnumerator TestScene2()
 {
     // The scene used here is set up in BuildSetupAndCleanup.cs
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("SampleTestScene"));
 }
示例#11
0
 public IEnumerator InputExperienceRecenter()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("InputExperienceRecenter"));
 }
示例#12
0
 public IEnumerator InputArrayForTracking()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("InputArrayForTracking"));
 }
示例#13
0
 public IEnumerator NameManfSerial()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("NameManfSerial"));
 }
示例#14
0
 public IEnumerator InputFeatureUsageTracking()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("InputFeatureUsageTracking"));
 }
示例#15
0
 public IEnumerator InputFeatureUsageControls()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("InputFeatureUsageControls"));
 }
示例#16
0
 public IEnumerator InputHaptics()
 {
     yield return(TestHelperFunctions.RunFacilitatorSceneTest("InputHaptics"));
 }