Ejemplo n.º 1
0
        public void ShouldCacheSubsequantCallsToQuery()
        {
            var getJobsQuery    = Substitute.For <IGetJobsQuery>();
            var getJobSpecQuery = Substitute.For <IGetJobSpecQuery>();
            var cache           = new InMemoryCache();
            var getJobsService  = new GetJobsService(getJobsQuery, getJobSpecQuery, cache);

            getJobsService.GetAsync();
            getJobsService.GetAsync();
            getJobsService.GetAsync();

            getJobsQuery.Received(1).Execute();
        }
Ejemplo n.º 2
0
        public void ShouldReturnJobSpec()
        {
            var fixture         = new Fixture();
            var jobSpec         = fixture.Create <string>();
            var getJobsQuery    = Substitute.For <IGetJobsQuery>();
            var getJobSpecQuery = Substitute.For <IGetJobSpecQuery>();

            getJobSpecQuery.Execute(Arg.Any <string>()).Returns(jobSpec);
            var cache          = new InMemoryCache();
            var getJobsService = new GetJobsService(getJobsQuery, getJobSpecQuery, cache);

            var results = getJobsService.GetSpecAsync("").Result;

            results.Details.ShouldEqual(jobSpec);
        }
Ejemplo n.º 3
0
        public void ShouldReturnAllJobs()
        {
            var fixture         = new Fixture();
            var jobs            = fixture.Build <JobSummary>().CreateMany(5);
            var getJobsQuery    = Substitute.For <IGetJobsQuery>();
            var getJobSpecQuery = Substitute.For <IGetJobSpecQuery>();

            getJobsQuery.Execute().Returns(jobs);
            var cache          = new InMemoryCache();
            var getJobsService = new GetJobsService(getJobsQuery, getJobSpecQuery, cache);

            var results = getJobsService.GetAsync().Result;

            results.Jobs.Count.ShouldEqual(5);
        }