public void CanOverrideDefaultResultForType()
        {
            var synth = new ResultSynthesizer();
            string newResult = "new result";
            synth.SetResult(typeof (string), newResult);

            AssertReturnsValue(synth, typeof (string), newResult);
        }
        public void CanSpecifyResultForOtherType()
        {
            var synth = new ResultSynthesizer();
            var value = new NamedObject("value");
            synth.SetResult(typeof (NamedObject), value);

            AssertReturnsValue(synth, typeof (NamedObject), value);
        }
        public void CreatesDefaultValuesForBasicTypes()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (bool), false);
            AssertReturnsValue(synth, typeof (byte), (byte) 0);
            AssertReturnsValue(synth, typeof (sbyte), (sbyte) 0);
            AssertReturnsValue(synth, typeof (short), (short) 0);
            AssertReturnsValue(synth, typeof (ushort), (ushort) 0U);
            AssertReturnsValue(synth, typeof (int), 0);
            AssertReturnsValue(synth, typeof (uint), 0U);
            AssertReturnsValue(synth, typeof (long), 0L);
            AssertReturnsValue(synth, typeof (ulong), 0UL);
            AssertReturnsValue(synth, typeof (char), '\0');
            AssertReturnsValue(synth, typeof (string), "");
        }
        public void DoesNotTryToSetResultForVoidReturnType()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (void), Missing.Value);
        }
        public void ThrowsExceptionIfTriesToReturnValueForUnsupportedResultType()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (NamedObject), Is.Nothing);
        }
        public void ReturnsZeroLengthArrays()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (int[]), new int[0]);
            AssertReturnsValue(synth, typeof (string[]), new string[0]);
            AssertReturnsValue(synth, typeof (object[]), new object[0]);
        }
        public void ReturnsEmptyCollections()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (ArrayList), IsAnEmpty(typeof (ArrayList)));
            AssertReturnsValue(synth, typeof (SortedList), IsAnEmpty(typeof (SortedList)));
            AssertReturnsValue(synth, typeof (Hashtable), IsAnEmpty(typeof (Hashtable)));
            AssertReturnsValue(synth, typeof (Stack), IsAnEmpty(typeof (Stack)));
            AssertReturnsValue(synth, typeof (Queue), IsAnEmpty(typeof (Queue)));
        }
        public void ReturnsDefaultValueOfValueTypes()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof (DateTime), new DateTime());
            AssertReturnsValue(synth, typeof (AValueType), new AValueType());
        }
        public void ReturnsADifferentCollectionOnEachInvocation()
        {
            var synth = new ResultSynthesizer();
            var list = (ArrayList) ValueReturnedForType(synth, typeof (ArrayList));
            list.Add("a new element");

            AssertReturnsValue(synth, typeof (ArrayList), IsAnEmpty(typeof (ArrayList)));
        }