Beispiel #1
0
        public void ShouldBeAbleToResolveNestedAndChainedSetups()
        {
            var magic = new MagicMoq.Moqer();

            magic.Setup <ISessionFactory, ISession>(a => a.OpenSession()).AndResolveWith(magic);
            magic.Setup <ISession, ITransaction>(a => a.OpenTransaction()).AndResolveWith(magic);

            var someoneThatUseSessionFactory = magic.Resolve <SomeoneThatUseISessionFactory>();

            someoneThatUseSessionFactory.DoSomething();

            magic.Verify <ISessionFactory>(a => a.OpenSession(), Times.Once());
            magic.Verify <ISession>(a => a.OpenTransaction(), Times.Once());
            magic.Verify <ISession>(a => a.DoSomething(), Times.Once());
            magic.Verify <ITransaction>(a => a.Commit(), Times.Once());
        }
Beispiel #2
0
        public void ShouldBeAbleToResolveNestedAndChainedSetups()
        {
            var magic = new MagicMoq.Moqer();

            magic.Setup<ISessionFactory, ISession>(a => a.OpenSession()).AndResolveWith(magic);
            magic.Setup<ISession, ITransaction>(a => a.OpenTransaction()).AndResolveWith(magic);

            var someoneThatUseSessionFactory = magic.Resolve<SomeoneThatUseISessionFactory>();

            someoneThatUseSessionFactory.DoSomething();

            magic.Verify<ISessionFactory>(a => a.OpenSession(), Times.Once());
            magic.Verify<ISession>(a => a.OpenTransaction(), Times.Once());
            magic.Verify<ISession>(a => a.DoSomething(), Times.Once());
            magic.Verify<ITransaction>(a => a.Commit(), Times.Once());
        }
Beispiel #3
0
        public void ShouldCreateClassWithDependenciesAndVerify_WithMoqAPI()
        {
            var magic = new MagicMoq.Moqer();
            var foo   = magic.Resolve <Foo>();

            foo.DoSomething();

            magic.Verify <IFooDependency>(a => a.DoSomethingDifferent(), Times.Once());
        }
Beispiel #4
0
        public void ShouldCreateClassWithDependenciesAndVerify_WithMoqAPI()
        {
            var magic = new MagicMoq.Moqer();
            var foo = magic.Resolve<Foo>();

            foo.DoSomething();

            magic.Verify<IFooDependency>(a => a.DoSomethingDifferent(), Times.Once());
        }