[InlineData(" ")] //Whitespace string public void Send_ShouldThrowArgumentNullException_WithInvalidMessage(string messageToTest) { var testService = new TwilioSmsService(Options.Create(_options)); var recipient = "+15555551212"; var exception = Assert.Throws <ArgumentNullException>(() => testService.Send(recipient, messageToTest)); Assert.Equal("message", exception.ParamName); }
[InlineData(" ")] //Whitespace string public void Send_ShouldThrowArgumentNullException_WithInvalidRecipient(string recipientToTest) { // Arrange var testService = new TwilioSmsService(Options.Create(_options)); var message = "Valid Message"; // Act var exception = Assert.Throws <ArgumentNullException>(() => testService.Send(recipientToTest, message)); // Assert Assert.Equal("recipient", exception.ParamName); }
public void Send_ShouldExecuteWithoutError_WithValidInputs() { //Arrange _options.FromPhoneNumber = "+15005550006"; var recipient = "+15155551212"; var message = "Sent from Unit Test"; var testService = new TwilioSmsService(Options.Create(_options)); //Act testService.Send(recipient, message); //Assert //TODO: Production implementation should have a return value to be able to validate success. Assert.True(true); }
public void Send_ShouldThrowTwilioError_WhenInvalidPhoneNumberIsUsed() { // Arrange _options.FromPhoneNumber = "+15005550001"; //Magic number for invalid var expectedErrorCode = 21212; var recipient = "+15555551212"; var message = "Testing"; var testService = new TwilioSmsService(Options.Create(_options)); // Act var exception = Assert.Throws <ApiException>(() => testService.Send(recipient, message)); // Assert Assert.Equal(expectedErrorCode, exception.Code); }