Ejemplo n.º 1
0
 protected static IEnumerable <Tuple <Error, Error> > GetUnequalObjects()
 {
     return(new List <Tuple <Error, Error> >
     {
         new Tuple <Error, Error>(TestErrors.TestErrorOne, TestErrors.TestErrorTwo),
         new Tuple <Error, Error>(TestErrors.TestErrorTwo, TestErrors.TestErrorOne),
         new Tuple <Error, Error>(TestErrors.TestErrorTwo, TestErrors.TestErrorThree("3")),
     });
 }
Ejemplo n.º 2
0
 protected static IEnumerable <Tuple <Error, Error> > GetEqualObjects()
 {
     return(new List <Tuple <Error, Error> >
     {
         new Tuple <Error, Error>(TestErrors.TestErrorOne, TestErrors.TestErrorOne),
         new Tuple <Error, Error>(TestErrors.TestErrorThree("three"), TestErrors.TestErrorThree("three")),
         new Tuple <Error, Error>(TestErrors.TestErrorThree("four"), TestErrors.TestErrorThree("three")),
         new Tuple <Error, Error>(TestErrors.TestErrorThree("three"), TestErrors.TestErrorThree("four")),
     });
 }
        public void IF_No_error_is_provided_SHOULD_return_true_if_string_is_in_error_format()
        {
            //Arrange
            var serializedError = TestErrors.TestErrorThree("one example").ToString();

            //Act
            var result = serializedError.IsError();

            //Assert
            Assert.IsTrue(result);
        }
        public void IsError_SHOULD_return_TRUE_if_ErrorCode_same_but_Description_different()
        {
            //Arrange
            var serializedError = TestErrors.TestErrorThree("one example").ToString();

            //Act
            var result = serializedError.IsError(TestErrors.TestErrorThree(""));

            //Assert
            Assert.IsTrue(result);
        }
        public void SHOULD_use_name_of_property_as_code()
        {
            var resultOne   = TestErrors.TestErrorOne;
            var resultTwo   = TestErrors.TestErrorTwo;
            var resultThree = TestErrors.TestErrorThree("three times");

            Assert.AreEqual("TestErrorOne", resultOne.Code);
            Assert.AreEqual("Description One", resultOne.Description);
            Assert.AreEqual("TestErrorTwo", resultTwo.Code);
            Assert.AreEqual("Description Two", resultTwo.Description);
            Assert.AreEqual("TestErrorThree", resultThree.Code);
            Assert.AreEqual("Description Three: three times", resultThree.Description);
        }
Ejemplo n.º 6
0
        public void SHOULD_deserialize_properly_when_Description_has_params()
        {
            //Arrange
            var sut        = TestErrors.TestErrorThree("wow");
            var serialized = sut.ToString();

            //Act
            var result = Error.Deserialize(serialized);

            //Assert
            Assert.AreEqual("TestErrorThree ::: Description Three: wow", result.ToString());
            Assert.AreEqual(sut.Code, result.Code);
            Assert.AreEqual(sut.Description, result.Description);
        }
        public void IF_Result_failure_is_different_serialized_Error_SHOULD_return_false()
        {
            //Arrange
            var failOne   = Result.Failure(TestErrors.TestErrorOne.ToString());
            var failTwo   = Result.Failure <int>(TestErrors.TestErrorTwo.ToString());
            var failThree = Result.Failure(TestErrors.TestErrorThree("three").ToString());
            var failFour  = Result.Failure(TestErrors.TestErrorThree("four").ToString());

            //Act
            var resultOne   = failOne.IsError(TestErrors.TestErrorTwo);
            var resultTwo   = failTwo.IsError(TestErrors.TestErrorThree("four"));
            var resultThree = failThree.IsError(TestErrors.TestErrorTwo);
            var resultFour  = failThree.IsError(TestErrors.TestErrorOne);

            //Assert
            Assert.IsFalse(resultOne);
            Assert.IsFalse(resultTwo);
            Assert.IsFalse(resultThree);
            Assert.IsFalse(resultFour);
        }