public void SuccessfulOpRes_ImplicitCastToBool_True() { //Arrange var opRes = new NamedOperationResult(success: true); //Act bool success = opRes; //Assert Assert.IsTrue(success); }
public void FailedOpRes_ImplicitCastToBool_False() { //Arrange var opRes = new NamedOperationResult(success: false); //Act bool success = opRes; //Assert Assert.IsFalse(success); }
public void SuccessfulOperationPropertyResult_ValuesMatch() { //Act var opRes = new NamedOperationResult(true); //Assert Assert.IsTrue(opRes.Success); Assert.IsNull(opRes.ErrorMessage); Assert.AreEqual( nameof(SuccessfulOperationPropertyResult_ValuesMatch), opRes.OperationName); }
public void WithExceptionInnerExceptionWithErrorMessageCtor_FailedOpResWithMatchingErrorMessage() { //Arrange var exception = new Exception("Error message 1", innerException: new Exception("Error message 2")); //Act var opRes = new NamedOperationResult(exception); //Assert Assert.IsFalse(opRes.Success); // ReSharper disable once PossibleNullReferenceException Assert.AreEqual(exception.InnerException.Message, opRes.ErrorMessage); AssertOperationNameMatchCaller(opRes); }
public void ErrorMessageCtor_FailedOperationResultWithMatchingErrorMessageCreated() { //Arrange const bool expectedSuccessIndication = false; const string expectedErrorMessage = "Some error message"; //Act var opRes = new NamedOperationResult(expectedErrorMessage); //Assert Assert.AreEqual(expectedSuccessIndication, opRes.Success, $"Expected {nameof(opRes.Success)} '{opRes.Success}' to match '{expectedSuccessIndication}'"); Assert.AreEqual(expectedErrorMessage, opRes.ErrorMessage, $"Expected {nameof(opRes.ErrorMessage)} '{opRes.ErrorMessage}' to match '{expectedErrorMessage}'"); AssertOperationNameMatchCaller(opRes); }