public void Init_Timers_only_registers_once()
        {
            for (int i = 0; i < 2; i++)
            {
                var fakeTimer = new FakeJob();
                IEnumerable <IJob> BaseFakeJobs = new List <IJob> {
                    fakeTimer
                };

                Mocker.SetConstant(BaseFakeJobs);

                var jobProvider = Mocker.Resolve <JobProvider>();
                jobProvider.Initialize();
            }

            var Mocker2 = new AutoMoqer();

            Mocker2.SetConstant(Db);
            var assertjobProvider = Mocker2.Resolve <JobProvider>();
            var timers            = assertjobProvider.All();

            //Assert
            timers.Should().HaveCount(1);
            timers[0].Enable.Should().BeTrue();
        }
Exemple #2
0
        public static TInterface Resolve <TInterface, TService>(this AutoMoqer mocker)
            where TService : TInterface
        {
            var service = mocker.Resolve <TService>();

            mocker.SetConstant <TInterface>(service);
            return(service);
        }
        public void Init_Timers_only_registers_once()
        {
            for (int i = 0; i < 2; i++)
            {
                var fakeTimer = new FakeJob();
                IList<IJob> BaseFakeJobs = new List<IJob> { fakeTimer };

                Mocker.SetConstant(BaseFakeJobs);

                var jobProvider = Mocker.Resolve<JobProvider>();
                jobProvider.Initialize();
            }

            var Mocker2 = new AutoMoqer();

            Mocker2.SetConstant(Db);
            var assertjobProvider = Mocker2.Resolve<JobProvider>();
            var timers = assertjobProvider.All();

            //Assert
            timers.Should().HaveCount(1);
            timers[0].Enable.Should().BeTrue();
        }