Esempio n. 1
0
        public void shouldMapErrorsAndKeepInners()
        {
            SafeResult<bool> firstResult = new SafeResult<bool>();

            firstResult.logError("test error");

            SafeResult<bool> secondResult = new SafeResult<bool>();

            Assert.AreEqual(1,firstResult.Errors.Count);

            secondResult.mapErrors(firstResult);

            Assert.AreEqual(1,secondResult.Errors.Count);
            Assert.AreEqual(1,secondResult.Inner.Errors.Count);

            Assert.AreEqual(1,firstResult.Errors.Count);
        }
Esempio n. 2
0
        public void shouldChainMapping()
        {
            SafeResult<bool> firstResult = new SafeResult<bool>{ Status = SAFE_RESULT.Success };

            firstResult.logError("test error");

            SafeResult<bool> secondResult = new SafeResult<bool>();

            Assert.AreEqual(1,firstResult.Errors.Count);
            Assert.AreEqual(SAFE_RESULT.Success, firstResult.Status);

            secondResult.mapErrors(firstResult).mapStatus();

            //check outer
            Assert.AreEqual(1,secondResult.Errors.Count);
            Assert.AreEqual(SAFE_RESULT.Success, secondResult.Status);

            //check inner
            Assert.AreEqual(1,secondResult.Inner.Errors.Count);
            Assert.AreEqual(SAFE_RESULT.Success, secondResult.Inner.Status);

            Assert.AreEqual(1,firstResult.Errors.Count);
        }