public void ParseReportMetadataList_ParseErrorReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestDescription"": ""error"", ""TestReportType"": ""ErrorReport"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as ErrorReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal("error", reportMetadata.TestDescription); Assert.Equal(TestOperationResultType.Error, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.ErrorReport, reportMetadata.TestReportType); Assert.Equal(TestConstants.Error.TestResultSource, reportMetadata.Source); }
public void ParseReportMetadataList_ParseNetworkControllerReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestDescription"": ""network controller"", ""TestReportType"": ""NetworkControllerReport"", ""Source"": ""networkController"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as NetworkControllerReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal("network controller", reportMetadata.TestDescription); Assert.Equal(TestOperationResultType.Network, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.NetworkControllerReport, reportMetadata.TestReportType); Assert.Equal("networkController", reportMetadata.Source); }
public void ParseReportMetadataList_ParseDeploymentTestReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestReportType"": ""DeploymentTestReport"", ""ExpectedSource"": ""deploymentTester1.send"", ""ActualSource"": ""deploymentTester2.receive"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as DeploymentTestReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal(TestOperationResultType.Deployment, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.DeploymentTestReport, reportMetadata.TestReportType); Assert.Equal("deploymentTester1.send", reportMetadata.ExpectedSource); Assert.Equal("deploymentTester2.receive", reportMetadata.ActualSource); }
public void ParseReportMetadataList_MultipleReportMetadata() { const string testDataJson = @"{ ""reportMetadata1"": { ""TestReportType"": ""CountingReport"", ""TestOperationResultType"": ""Messages"", ""ExpectedSource"": ""loadGen1.send"", ""ActualSource"": ""relayer1.receive"" }, ""reportMetadata2"": { ""TestReportType"": ""TwinCountingReport"", ""TwinTestPropertyType"": ""Desired"", ""ExpectedSource"": ""twinTester1.desiredUpdated"", ""ActualSource"": ""twinTester2.desiredReceived"" }, ""reportMetadata3"": { ""TestReportType"": ""DeploymentTestReport"", ""ExpectedSource"": ""deploymentTester1.send"", ""ActualSource"": ""deploymentTester2.receive"" }, ""reportMetadata4"": { ""TestReportType"": ""DirectMethodReport"", ""SenderSource"": ""senderSource1.send"", ""ReceiverSource"": ""receiverSource1.receive"", ""TolerancePeriod"": ""00:00:00.005"" }, ""reportMetadata5"": { ""TestReportType"": ""DirectMethodReport"", ""SenderSource"": ""senderSource1.send"", ""TolerancePeriod"": ""00:00:00.005"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Equal(5, results.Count); }
public void ParseReportMetadataList_ParseDirectMethodTestReportMetadataWithoutReceiverSource() { const string testDataJson = @"{ ""reportMetadata"": { ""TestReportType"": ""DirectMethodReport"", ""SenderSource"": ""directMethodSender1.send"", ""TolerancePeriod"": ""00:00:00.005"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as DirectMethodReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal(TestOperationResultType.DirectMethod, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.DirectMethodReport, reportMetadata.TestReportType); Assert.Equal("directMethodSender1.send", reportMetadata.SenderSource); Assert.False(reportMetadata.ReceiverSource.HasValue); Assert.Equal(new TimeSpan(0, 0, 0, 0, 5), reportMetadata.TolerancePeriod); }
public void ParseReportMetadataList_ParseCountingReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestReportType"": ""CountingReport"", ""TestOperationResultType"": ""Messages"", ""ExpectedSource"": ""loadGen1.send"", ""ActualSource"": ""relayer1.receive"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as CountingReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal(TestOperationResultType.Messages, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.CountingReport, reportMetadata.TestReportType); Assert.Equal("loadGen1.send", reportMetadata.ExpectedSource); Assert.Equal("relayer1.receive", reportMetadata.ActualSource); }
public void ParseReportMetadataList_ParseEdgeHubRestartDirectMethodReportMetadata() { const string testDataJson = @"{ ""reportMetadata7"": { ""TestReportType"": ""EdgeHubRestartDirectMethodReport"", ""TestOperationResultType"": ""EdgeHubRestartDirectMethod"", ""SenderSource"": ""edgeHubRestartTester1.EdgeHubRestartDirectMethod"", ""ReceiverSource"": ""directMethodReceiver1.receive"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as EdgeHubRestartDirectMethodReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal(TestOperationResultType.EdgeHubRestartDirectMethod, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.EdgeHubRestartDirectMethodReport, reportMetadata.TestReportType); Assert.Equal("edgeHubRestartTester1.EdgeHubRestartDirectMethod", reportMetadata.SenderSource); Assert.Equal("directMethodReceiver1.receive", reportMetadata.ReceiverSource); }
public void ParseReportMetadataList_ParseDirectMethodLongHaulTestReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestDescription"": ""direct method | cloud | amqp"", ""TestReportType"": ""DirectMethodLongHaulReport"", ""SenderSource"": ""directMethodSender1.send"", ""ReceiverSource"": ""directMethodReceiver1.receive"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as DirectMethodLongHaulReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal("direct method | cloud | amqp", reportMetadata.TestDescription); Assert.Equal(TestOperationResultType.DirectMethod, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.DirectMethodLongHaulReport, reportMetadata.TestReportType); Assert.Equal("directMethodSender1.send", reportMetadata.SenderSource); Assert.Equal("directMethodReceiver1.receive", reportMetadata.ReceiverSource); }
public void ParseReportMetadataList_ThrowExceptionWhenParseInvalidData() { const string testDataJson = @"{ ""reportMetadata"": { ""TestReportType"": ""TypeNotExist"", ""ExpectedSource"": ""deploymentTester1.send"", ""ActualSource"": ""deploymentTester2.receive"" } }"; bool exceptionThrown = false; try { TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); } catch (Exception) { exceptionThrown = true; } Assert.True(exceptionThrown); }
public void ParseReportMetadataList_ParseTwinCountingReportMetadata() { const string testDataJson = @"{ ""reportMetadata"": { ""TestReportType"": ""TwinCountingReport"", ""TwinTestPropertyType"": ""Desired"", ""ExpectedSource"": ""twinTester1.desiredUpdated"", ""ActualSource"": ""twinTester2.desiredReceived"" } }"; List <ITestReportMetadata> results = TestReportUtil.ParseReportMetadataJson(testDataJson, new Mock <ILogger>().Object); Assert.Single(results); var reportMetadata = results[0] as TwinCountingReportMetadata; Assert.NotNull(reportMetadata); Assert.Equal(TestOperationResultType.Twin, reportMetadata.TestOperationResultType); Assert.Equal(TestReportType.TwinCountingReport, reportMetadata.TestReportType); Assert.Equal(TwinTestPropertyType.Desired, reportMetadata.TwinTestPropertyType); Assert.Equal("twinTester1.desiredUpdated", reportMetadata.ExpectedSource); Assert.Equal("twinTester2.desiredReceived", reportMetadata.ActualSource); }