예제 #1
0
        public void ReturnsDefaultValueOfValueTypes()
        {
            var synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof(DateTime), new DateTime());
            AssertReturnsValue(synth, typeof(AValueType), new AValueType());
        }
예제 #2
0
        public void ReturnsZeroLengthArrays()
        {
            ResultSynthesizer synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof(int[]), new int[0]);
            AssertReturnsValue(synth, typeof(string[]), new string[0]);
            AssertReturnsValue(synth, typeof(object[]), new object[0]);
        }
예제 #3
0
        public void CanOverrideDefaultResultForType()
        {
            ResultSynthesizer synth     = new ResultSynthesizer();
            string            newResult = "new result";

            synth.SetResult(typeof(string), newResult);

            AssertReturnsValue(synth, typeof(string), newResult);
        }
예제 #4
0
        public void CanSpecifyResultForOtherType()
        {
            var synth = new ResultSynthesizer();
            var value = new NamedObject("value");

            synth.SetResult(typeof(NamedObject), value);

            AssertReturnsValue(synth, typeof(NamedObject), value);
        }
예제 #5
0
        public void ReturnsADifferentCollectionOnEachInvocation()
        {
            ResultSynthesizer synth = new ResultSynthesizer();
            ArrayList         list  = (ArrayList)ValueReturnedForType(synth, typeof(ArrayList));

            list.Add("a new element");

            AssertReturnsValue(synth, typeof(ArrayList), IsAnEmpty(typeof(ArrayList)));
        }
예제 #6
0
        public void ReturnsEmptyCollections()
        {
            ResultSynthesizer 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)));
        }
예제 #7
0
        public void CreatesDefaultValuesForBasicTypes()
        {
            ResultSynthesizer 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), "");
        }
예제 #8
0
        public void DoesNotTryToSetResultForVoidReturnType()
        {
            ResultSynthesizer synth = new ResultSynthesizer();

            AssertReturnsValue(synth, typeof(void), Missing.Value);
        }
예제 #9
0
        public void ThrowsExceptionIfTriesToReturnValueForUnsupportedResultType()
        {
            var synth = new ResultSynthesizer();

            Expect.That(() => AssertReturnsValue(synth, typeof(NamedObject), Is.Nothing)).Throws <InvalidOperationException>();
        }