public void GIVEN_on_happy_path_WHEN_check_transmission_THEN_get_diagnostic_response() { // Given TelemetryDiagnosticControls telemetryDiagnosticControls = new TelemetryDiagnosticControls(new TestingTelemetryClient(2, 51, 41)); // When telemetryDiagnosticControls.CheckTransmission(); // Then string message = "LAST TX rate................ 100 MBPS\r\n" + "HIGHEST TX rate............. 100 MBPS\r\n" + "LAST RX rate................ 100 MBPS\r\n" + "HIGHEST RX rate............. 100 MBPS\r\n" + "BIT RATE.................... 100000000\r\n" + "WORD LEN.................... 16\r\n" + "WORD/FRAME.................. 511\r\n" + "BITS/FRAME.................. 8192\r\n" + "MODULATION TYPE............. PCM/FM\r\n" + "TX Digital Los.............. 0.75\r\n" + "RX Digital Los.............. 0.10\r\n" + "BEP Test.................... -5\r\n" + "Local Rtrn Count............ 00\r\n" + "Remote Rtrn Count........... 00"; Assert.AreEqual(message, telemetryDiagnosticControls.DiagnosticInfo); }
public void GIVEN_on_happy_path_WHEN_check_transmission_THEN_get_diagnostic_response() { // Given TelemetryDiagnosticControls telemetryDiagnosticControls = new TelemetryDiagnosticControls(new TestingTelemetryClient(2, 51, 41)); // When telemetryDiagnosticControls.CheckTransmission(); // Then string message = "LAST TX rate................ 100 MBPS\r\n" + "HIGHEST TX rate............. 100 MBPS\r\n" + "LAST RX rate................ 100 MBPS\r\n" + "HIGHEST RX rate............. 100 MBPS\r\n" + "BIT RATE.................... 100000000\r\n" + "WORD LEN.................... 16\r\n" + "WORD/FRAME.................. 511\r\n" + "BITS/FRAME.................. 8192\r\n" + "MODULATION TYPE............. PCM/FM\r\n" + "TX Digital Los.............. 0.75\r\n" + "RX Digital Los.............. 0.10\r\n" + "BEP Test.................... -5\r\n" + "Local Rtrn Count............ 00\r\n" + "Remote Rtrn Count........... 00"; Assert.AreEqual(message, telemetryDiagnosticControls.DiagnosticInfo); }
public void WhenCheckTransmissionAndCannotConnectAfterThreeTries_ThenThrowException() { int trialCountToConnect = 4; TelemetryDiagnosticControls tdc = new TelemetryDiagnosticControls(new FakeTelemetryClient(trialCountToConnect)); Assert.Throws <Exception>(() => tdc.CheckTransmission()); }
// A class with the only goal of simulating a dependency on TelemetryDiagnosticControls // that has impact on the refactoring. public TelemetryDiagnosticControlsClient1() { var teleDiagnostic = new TelemetryDiagnosticControls(); teleDiagnostic.CheckTransmission(); var result = teleDiagnostic.DiagnosticInfo; }
public void WhenCheckTransmissionAndSuccessfulConnect_ThenSendRequestAndReceiveDiagnosticInfo() { int trialCountToConnect = 2; TelemetryDiagnosticControls tdc = new TelemetryDiagnosticControls(new FakeTelemetryClient(trialCountToConnect)); tdc.CheckTransmission(); Assert.AreEqual("Fake Diagnostic Info", tdc.DiagnosticInfo); }
public void Receive_diagnostics_info_When_CheckTransmission() { var nextReturnThisMakesSuccessfulConnection = 1; var client = TelemetryClientForTest.SetUp(nextReturnThisMakesSuccessfulConnection); var telemetryDiagnosticControls = new TelemetryDiagnosticControls(client); var diagnosticsResult = telemetryDiagnosticControls.CheckTransmission(); Check.That(diagnosticsResult).IsEqualTo(Channel.SimulatedDiagnosticMessageResult); }
public void GIVEN_not_online_to_server_WHEN_check_transmission_THEN_get_exception() { // Given TelemetryDiagnosticControls telemetryDiagnosticControls = new TelemetryDiagnosticControls(new TestingTelemetryClient(3, 51, 41)); // When var exception = Assert.Throws <Exception>(() => telemetryDiagnosticControls.CheckTransmission()); // Then Assert.That(exception.Message, Is.EqualTo("Unable to connect.")); }
public void GIVEN_not_online_to_server_WHEN_check_transmission_THEN_get_exception() { // Given TelemetryDiagnosticControls telemetryDiagnosticControls = new TelemetryDiagnosticControls(new TestingTelemetryClient(3, 51, 41)); // When var exception = Assert.Throws<Exception>(() => telemetryDiagnosticControls.CheckTransmission()); // Then Assert.That(exception.Message, Is.EqualTo("Unable to connect.")); }
public void Receive_diagnostics_info_When_client_try_connect_twice_and_finished_by_connected_then_CheckTransmission() { var connectionSimulator = Simulate_client_try_connect_twice_and_finished_by_connected(); var telemetryClient = new TelemetryClient(new Connector(connectionSimulator), new Channel(connectionSimulator)); var telemetryDiagnosticControls = new TelemetryDiagnosticControls(telemetryClient); var diagnosticsResult = telemetryDiagnosticControls.CheckTransmission(); Check.That(diagnosticsResult).IsEqualTo(Channel.SimulatedDiagnosticMessageResult); }
public void CheckTransmission_fails_When_client_connection_fail() { var nextReturnThisMakesSuccessfulConnection = 100; var client = TelemetryClientForTest.SetUp(nextReturnThisMakesSuccessfulConnection); var telemetryDiagnosticControls = new TelemetryDiagnosticControls(client); Check.ThatCode( () => { telemetryDiagnosticControls.CheckTransmission(); }) .Throws <Exception>() .WithMessage("Unable to connect."); }
public void CheckTransmission_fails_When_client_connection_retry_times_are_all_used() { var connectionSimulator = SimulateClientRetryConnect_three_times_fail(); var telemetryClient = new TelemetryClient(new Connector(connectionSimulator), new Channel(connectionSimulator)); var telemetryDiagnosticControls = new TelemetryDiagnosticControls(telemetryClient); Check.ThatCode( () => { telemetryDiagnosticControls.CheckTransmission(); }) .Throws <Exception>() .WithMessage("Unable to connect."); }
public void CheckTransmission_should_send_a_diagnostic_message_and_receive_a_status_message_response() { var stubTelemetryConnection = new StubTelemetryConnection(); stubTelemetryConnection.StubGetOnlineStatus(true); var mockTelemetryDataChannel = new MockTelemetryDataChannel(); mockTelemetryDataChannel.SetExpectedCallToSend(TelemetryDataChannel.DiagnosticMessage); mockTelemetryDataChannel.SetExpectedCallToReceive("status report"); var target = new TelemetryDiagnosticControls(stubTelemetryConnection, mockTelemetryDataChannel); target.CheckTransmission(); mockTelemetryDataChannel.Verify(); Assert.AreEqual(target.DiagnosticInfo, "status report", "diagnostic info"); }
public void GIVEN_online_status_of_TelemetryClient_is_tue_WHEN_check_Transmision_THEN_method_Disconnect_Send_and_Receive_should_be_invoked() { // Given var telemetryClient = new Mock<TelemetryClient>(); TelemetryDiagnosticControls telementryDiagnosticControls = new TelemetryDiagnosticControls(telemetryClient.Object); telemetryClient .Setup(t => t.OnlineStatus) .Returns(true); // When telementryDiagnosticControls.CheckTransmission(); // Then telemetryClient.Verify(t => t.Disconnect()); // telemetryClient.Verify(t => t.Connect("*111#")); // Why this line never performed? telemetryClient.Verify(t => t.Send("AT#UD")); telemetryClient.Verify(t => t.Receive()); }
public void CheckTransmission_should_send_a_diagnostic_message_and_receive_a_status_message_response() { StubTelemetryConnection stubTelemetryConnection = new StubTelemetryConnection(); stubTelemetryConnection.StubGetOnlineStatus(true); MockTelemetryDataChannel mockTelemetryDataChannel = new MockTelemetryDataChannel(); mockTelemetryDataChannel.SetExpectedCallToSend(TelemetryDataChannel.DiagnosticMessage); mockTelemetryDataChannel.SetExpectedCallToReceive("status report"); TelemetryDiagnosticControls target = new TelemetryDiagnosticControls(stubTelemetryConnection, mockTelemetryDataChannel); target.CheckTransmission(); mockTelemetryDataChannel.Verify(); Assert.AreEqual(target.DiagnosticInfo, "status report", "diagnostic info"); }
public void GIVEN_online_status_of_TelemetryClient_is_tue_WHEN_check_Transmision_THEN_method_Disconnect_Send_and_Receive_should_be_invoked() { // Given var telemetryClient = new Mock <TelemetryClient>(); TelemetryDiagnosticControls telementryDiagnosticControls = new TelemetryDiagnosticControls(telemetryClient.Object); telemetryClient .Setup(t => t.OnlineStatus) .Returns(true); // When telementryDiagnosticControls.CheckTransmission(); // Then telemetryClient.Verify(t => t.Disconnect()); // telemetryClient.Verify(t => t.Connect("*111#")); // Why this line never performed? telemetryClient.Verify(t => t.Send("AT#UD")); telemetryClient.Verify(t => t.Receive()); }
public void CheckTransmission_should_send_a_diagnostic_message_and_receive_a_status_message_response() { var channel = MockRepository.GenerateMock<ITelemetryChannel>(); var connetion = MockRepository.GenerateMock<IConnection>(); var telemetryConnection = new TelemetryConnector(connetion); using (channel.GetMockRepository().Ordered()) { connetion .Stub(client => client.OnlineStatus) .Return(false).Repeat.Once(); connetion .Stub(client => client.OnlineStatus) .Return(true); } channel .Stub(client => client.Receive()) .Return(ExpectedTelemetryClientResponse); var telemetryDiagnosticControls = new TelemetryDiagnosticControls(channel, telemetryConnection); telemetryDiagnosticControls.CheckTransmission(); connetion.AssertWasCalled(conn => conn.Connect(Arg<string>.Is.Anything)); channel.AssertWasCalled(client => client.Send(TelemetryClient.DiagnosticMessage)); Assert.That(telemetryDiagnosticControls.DiagnosticInfo, Is.EqualTo(ExpectedTelemetryClientResponse)); }