コード例 #1
0
ファイル: FeatureTests.cs プロジェクト: rmcfarlane82/Moqqer
        public void A_TestInit()
        {
            // Create instance of Moqqer
            _moq = new Moqqer();

            // Create an instance of SomeClass injecting mocks into constructor
        }
コード例 #2
0
 public static void Add <T>(this Moqqer moq, params T[] items)
 {
     foreach (var item in items)
     {
         moq.Add(item);
     }
 }
コード例 #3
0
 public static void AddItems <T>(this Moqqer moq, IEnumerable <T> items)
 {
     foreach (var item in items)
     {
         moq.Add(item);
     }
 }
コード例 #4
0
 public void A_TestSetup()
 {
     _moq      = new Moqqer();
     _comparer = IoC.Container.GetInstance <DataComparer>();
     _left     = Tables.Default;
     _right    = Tables.Default;
 }
コード例 #5
0
        public override object CreateGeneric <T>(Moqqer moq, Type type, Type openType)
        {
            var list = moq.List <T>();

            return(moq.UseMoqqerEnumerableQuery
                ? list.AsMoqqerQueryable()
                : list.AsQueryable());
        }
コード例 #6
0
        public override object CreateGeneric <T>(Moqqer moq, Type type, Type openType)
        {
            var list = moq.List <T>();

            var collection = new ObservableCollection <T>(list);

            collection.SetItems(list);

            return(collection);
        }
コード例 #7
0
        public override object CreateGeneric <T>(Moqqer moq, Type type, Type openType)
        {
            var instance = moq.GetInstance(typeof(T));

            // ReSharper disable once MergeConditionalExpression
            var result = instance is T
                ? (T)instance
                : default(T);

            return(TaskHelper.FromResult(result));
        }
コード例 #8
0
        public void DoWork_CallsRepositoryGetData()
        {
            // 1 -  First create an instance of Moqqer which will
            //      act as a container for Mocks and Objects.
            _moq = new Moqqer();

            // 2 -  Get Moqqer to create an instance of some class you want to test.
            // It will auto inject mocks in the its constructor.
            _subject = _moq.Create <SomeClass>();

            // 3 -  Call the mothod you want to test on SomeClass
            _subject.CallA(); // Calls private field IDependencyA.Call()

            // 4 -  Verify a mock that was auto injected was called.
            _moq.Of <IDepencyA>()
            .Verify(x => x.Call(), Times.Once);

            //      Alternatively use the Verify extension method
            _moq.Verify <IDepencyA>(x => x.Call())
            .Once();

            // 5 -  Test and Refactor to your hearts content
            //      without worrying about changing the constructor calls!
        }
コード例 #9
0
        public object Create(Moqqer moq, Type type, Type openType, Type[] genericArguments)
        {
            var meth = CreateGenericMethodInfo.MakeGenericMethod(genericArguments);

            return(meth.Invoke(this, new object[] { moq, type, openType }));
        }
コード例 #10
0
 public static MoqFluentVerifyBuilder <T> .IHasVerifyAction Verify <T>
     (this Moqqer moq, Expression <Action <T> > action)
     where T : class
 {
     return(new MoqFluentVerifyBuilder <T>(moq.Of <T>(), action));
 }
コード例 #11
0
 public bool CanHandle(Moqqer moq, Type type, Type openType, Type[] genericArguments)
 {
     return(typeof(List <>)
            .IsOpenGenericAssignableToOpenGenericType(openType));
 }
コード例 #12
0
 private bool AreMockable(Moqqer moq, Type type)
 {
     return(moq.CanGetDefaultOrMock(type));
 }
コード例 #13
0
 public static void Add <T>(this Moqqer moq, T item)
 {
     moq.List <T>().Add(item);
 }
コード例 #14
0
ファイル: ListDefaultFactory.cs プロジェクト: zrajnai/Moqqer
        internal object GetOrCreateList(Moqqer moq, Type[] genericArguments)
        {
            var listType = typeof(List <>).MakeGenericType(genericArguments);

            return(moq.GetOrCreateObject(listType));
        }
コード例 #15
0
ファイル: ListDefaultFactory.cs プロジェクト: zrajnai/Moqqer
 public object Create(Moqqer moq, Type type, Type openType, Type[] genericArguments)
 {
     return(GetOrCreateList(moq, genericArguments));
 }
コード例 #16
0
 public override bool CanHandle(Moqqer moq, Type type, Type openType, Type[] genericArguments)
 {
     return(openType == typeof(Task <>) && genericArguments.All(x => AreMockable(moq, x)));
 }
コード例 #17
0
 public void A_TestSetup()
 {
     _moq  = new Moqqer();
     _root = _moq.Create <Root>();
 }
コード例 #18
0
 public abstract bool CanHandle(Moqqer moq, Type type, Type openType, Type[] genericArguments);
コード例 #19
0
 public override bool CanHandle(Moqqer moq, Type type, Type openType, Type[] genericArguments)
 {
     return(openType == typeof(IQueryable <>));
 }
コード例 #20
0
 public override bool CanHandle(Moqqer moq, Type type, Type openType, Type[] genericArguments)
 {
     return(openType == typeof(ObservableCollection <>));
 }
コード例 #21
0
ファイル: DefaultMocks.cs プロジェクト: zrajnai/Moqqer
 public void A_TestSetup()
 {
     _moq = new Moqqer();
 }
コード例 #22
0
 public abstract object CreateGeneric <T>(Moqqer moq, Type type, Type openType);