public void TestConstructorSuccess() { string senderSource = "senderSource"; Option <string> receiverSource = Option.Some("receiverSource"); int batchSize = 10; string resultType = "resultType1"; NetworkControllerType networkControllerType = NetworkControllerType.Offline; var mockSenderStore = new Mock <ISequentialStore <TestOperationResult> >(); IAsyncEnumerable <TestOperationResult> senderResults = new StoreTestResultCollection <TestOperationResult>(mockSenderStore.Object, batchSize); var mockReceiverStore = new Mock <ISequentialStore <TestOperationResult> >(); IAsyncEnumerable <TestOperationResult> receiverResults = new StoreTestResultCollection <TestOperationResult>(mockReceiverStore.Object, batchSize); Option <IAsyncEnumerator <TestOperationResult> > receiverResultsEnumerator = Option.Some <IAsyncEnumerator <TestOperationResult> >(receiverResults.GetAsyncEnumerator()); var reportGenerator = new DirectMethodConnectivityReportGenerator( TestDescription, Topology.SingleNode, Guid.NewGuid().ToString(), senderSource, senderResults.GetAsyncEnumerator(), receiverSource, receiverResultsEnumerator, resultType, NetworkStatusTimeline, networkControllerType); Assert.Equal(TestDescription, reportGenerator.TestDescription); Assert.Equal(receiverSource, reportGenerator.ReceiverSource); Assert.Equal(senderResults.GetAsyncEnumerator(), reportGenerator.SenderTestResults); Assert.Equal(senderSource, reportGenerator.SenderSource); Assert.Equal(receiverResultsEnumerator, reportGenerator.ReceiverTestResults); Assert.Equal(resultType, reportGenerator.ResultType); }
public async Task TestCreateReportAsyncWithEmptyResults() { string senderSource = "senderSource"; string receiverSource = "receiverSource"; int batchSize = 10; NetworkControllerType networkControllerType = NetworkControllerType.Offline; var mockSenderStore = new Mock <ISequentialStore <TestOperationResult> >(); IAsyncEnumerable <TestOperationResult> senderResults = new StoreTestResultCollection <TestOperationResult>(mockSenderStore.Object, batchSize); var mockReceiverStore = new Mock <ISequentialStore <TestOperationResult> >(); IAsyncEnumerable <TestOperationResult> receiverResults = new StoreTestResultCollection <TestOperationResult>(mockReceiverStore.Object, batchSize); Option <IAsyncEnumerator <TestOperationResult> > receiverResultsEnumerator = Option.Some <IAsyncEnumerator <TestOperationResult> >(receiverResults.GetAsyncEnumerator()); var reportGenerator = new DirectMethodConnectivityReportGenerator( TestDescription, Guid.NewGuid().ToString(), senderSource, senderResults.GetAsyncEnumerator(), Option.Some(receiverSource), receiverResultsEnumerator, "resultType1", NetworkStatusTimeline, networkControllerType); var report = (DirectMethodConnectivityReport)await reportGenerator.CreateReportAsync(); Assert.Equal(0UL, report.NetworkOnSuccess); Assert.Equal(0UL, report.NetworkOffSuccess); Assert.Equal(0UL, report.NetworkOnToleratedSuccess); Assert.Equal(0UL, report.NetworkOffToleratedSuccess); Assert.Equal(0UL, report.NetworkOnFailure); Assert.Equal(0UL, report.NetworkOffFailure); Assert.Equal(0UL, report.MismatchSuccess); Assert.Equal(0UL, report.MismatchFailure); }
public async Task TestCreateReportWithSenderResultsOnlyAsync( IEnumerable <ulong> senderStoreValues, IEnumerable <HttpStatusCode> statusCodes, IEnumerable <DateTime> timestamps, int batchSize, ulong expectedNetworkOnSuccess, ulong expectedNetworkOffSuccess, ulong expectedNetworkOnToleratedSuccess, ulong expectedNetworkOffToleratedSuccess, ulong expectedNetworkOnFailure, ulong expectedNetworkOffFailure, ulong expectedMismatchSuccess, ulong expectedMismatchFailure, bool expectedIsPassed, NetworkControllerType networkControllerType = NetworkControllerType.Offline) { string senderSource = "senderSource"; string resultType = TestOperationResultType.DirectMethod.ToString(); var mockSenderStore = new Mock <ISequentialStore <TestOperationResult> >(); IAsyncEnumerable <TestOperationResult> senderResults = new StoreTestResultCollection <TestOperationResult>(mockSenderStore.Object, batchSize); var mockReceiverStore = new Mock <ISequentialStore <TestOperationResult> >(); var receiverResultsEnumerator = Option.None <IAsyncEnumerator <TestOperationResult> >(); var reportGenerator = new DirectMethodConnectivityReportGenerator( TestDescription, Topology.SingleNode, Guid.NewGuid().ToString(), senderSource, senderResults.GetAsyncEnumerator(), Option.None <string>(), receiverResultsEnumerator, resultType, NetworkStatusTimeline, networkControllerType); var senderStoreData = GetSenderStoreData(senderSource, resultType, senderStoreValues, statusCodes, timestamps, Guid.NewGuid()); for (int i = 0; i < senderStoreData.Count; i += batchSize) { int startingOffset = i; mockSenderStore.Setup(s => s.GetBatch(startingOffset, batchSize)).ReturnsAsync(senderStoreData.Skip(startingOffset).Take(batchSize)); } var report = (DirectMethodConnectivityReport)await reportGenerator.CreateReportAsync(); Assert.Equal(expectedNetworkOnSuccess, report.NetworkOnSuccess); Assert.Equal(expectedNetworkOffSuccess, report.NetworkOffSuccess); Assert.Equal(expectedNetworkOnToleratedSuccess, report.NetworkOnToleratedSuccess); Assert.Equal(expectedNetworkOffToleratedSuccess, report.NetworkOffToleratedSuccess); Assert.Equal(expectedNetworkOnFailure, report.NetworkOnFailure); Assert.Equal(expectedNetworkOffFailure, report.NetworkOffFailure); Assert.Equal(expectedMismatchSuccess, report.MismatchSuccess); Assert.Equal(expectedMismatchFailure, report.MismatchFailure); Assert.Equal(expectedIsPassed, report.IsPassed); }