public void FormatException_when_exceptionType_not_found_uses_baseType_Layout() { // Arrange var formatter = ExceptionFormatter.Create() .AddExceptionLayout(new CustomerExceptionLayout()); // Act var subClassException = new CustomerNotFoundException(); var actual = formatter.FormatException(subClassException); // Assert actual.Should().MatchEquivalentOf("CustomerExceptionLayout*"); }
public static Customer EditCustomer(int Id) { // Pretend we look for the customer in our database // We can't find it, so we notify our caller in a way in // which they can't ignore us. string strMsg; strMsg = string.Format("The customer you requested by Id {0} could not be found.", Id); // Create the exception. CustomerNotFoundException exp = new CustomerNotFoundException(strMsg); // throw it to our caller throw exp; }
public void ShouldLocalizeException() { // Arrange var exception = new CustomerNotFoundException { CustomerId = "TestCustomerId" }; // Act var textEn = exception.GetLocalizedErrorCode("en"); var textDe = exception.GetLocalizedErrorCode("de"); // Assert Assert.False(string.IsNullOrEmpty(textEn)); Assert.False(string.IsNullOrEmpty(textDe)); }