Esempio n. 1
0
        public void FixturesShouldGetInserted()
        {
            FixturesHelper.StoreFakes((location) => _database.CodeLocations.Insert(location), 10, CodeLocationFixture.Fake);
            var locations = _database.CodeLocations.All();

            Assert.Equal(10, locations.Count());
        }
Esempio n. 2
0
            public void ShouldReturnAListOfJobs()
            {
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 5, JobFixture.CloneJob);

                var result = _harness.Controller.Index() as JsonResult;

                var jobs = result.DeserializeData <List <Job> >();

                jobs.Count.ShouldEqual(5);
            }
Esempio n. 3
0
            public void ShouldNotReturnJobsThatAreCompleted()
            {
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 5, JobFixture.CloneJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 4, () => JobFixture.CloneJob().Complete(10.Days().Ago()));

                var result = _harness.Controller.Index() as JsonResult;

                var jobs = result.DeserializeData <List <Job> >();

                jobs.Count.ShouldEqual(5);
            }
Esempio n. 4
0
            public void ShouldSupportTake()
            {
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 5, JobFixture.CloneJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 2, JobFixture.ImportJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 6, JobFixture.DetectAndHashJob);

                var result = _harness.Controller.Index(limit: 5) as JsonResult;

                var jobs = result.DeserializeData <List <Job> >();

                jobs.Count.ShouldEqual(5);
            }
Esempio n. 5
0
        public void FixturesShouldBeQueryable()
        {
            FixturesHelper.StoreFakes((location) => _database.CodeLocations.Insert(location), 10, CodeLocationFixture.Fake);
            FixturesHelper.StoreFakes((location) =>
            {
                location.IsPublic = true;
                _database.CodeLocations.Insert(location);
            }, 3, CodeLocationFixture.Fake);

            var privateLocations = _database.CodeLocations.FindAllBy(IsPublic: false);
            var publicLocations  = _database.CodeLocations.FindAllBy(IsPublic: true);

            Assert.Equal(10, privateLocations.Count());
            Assert.Equal(3, publicLocations.Count());
        }
Esempio n. 6
0
            public void ShouldSupportOffset()
            {
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 10, JobFixture.CloneJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 10, JobFixture.ImportJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 10, JobFixture.DetectAndHashJob);

                var allJobsInDb = (List <Job>)_database.Jobs.All();

                var result = _harness.Controller.Index(limit: 10, offset: 10) as JsonResult;

                var jobs = result.DeserializeData <List <Job> >();

                jobs.Count.ShouldEqual(10);
                jobs.First().Id.ShouldEqual(allJobsInDb[10].Id);
            }
Esempio n. 7
0
        public void FixturesShouldBeQueryableUsingAnInQuery()
        {
            var privateModels = FixturesHelper.StoreFakes((location) => _database.CodeLocations.Insert(location), 10, CodeLocationFixture.Fake);
            var publicModels  = FixturesHelper.StoreFakes((location) =>
            {
                location.IsPublic = false;
                _database.CodeLocations.Insert(location);
            }, 3, CodeLocationFixture.Fake);

            var publicNames = publicModels.Select(c => c.FullName).ToArray();

            var privateLocations = _database.CodeLocations.FindAllBy(IsPublic: false);
            var publicLocations  = _database.CodeLocations.FindAll(_database.CodeLocations.FullName == publicNames || _database.CodeLocations.IsPublic == true);

            Assert.Equal(13, privateLocations.Count());
            Assert.Equal(3, publicLocations.Count());
        }
Esempio n. 8
0
            public void ShoudlAllowFilteringByType()
            {
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 5, JobFixture.CloneJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 2, JobFixture.ImportJob);
                FixturesHelper.StoreFakes((job) => _database.Jobs.Insert(job), 6, JobFixture.DetectAndHashJob);

                var cases = new Dictionary <string, int>()
                {
                    { "Worker.Jobs.CloneJob", 5 },
                    { "Worker.Jobs.ImportJob", 2 },
                    { "Worker.Jobs.DetectAndHashJob", 6 }
                };

                foreach (var pair in cases)
                {
                    var result = _harness.Controller.Index(type: pair.Key) as JsonResult;

                    var jobs = result.DeserializeData <List <Job> >();

                    jobs.Count.ShouldEqual(pair.Value, $"{pair.Key} should have returned {pair.Value} items");
                }
            }
            public void ShouldReturnRepositories_ThatMatchCodeLocations()
            {
                var locations = FixturesHelper.StoreFakes((location) => _database.CodeLocations.Insert(location), 10, CodeLocationFixture.Fake)
                                .Take(5)
                                .Select(l => new GithubApiRepository()
                {
                    CloneUrl = "https://github.com/" + l.FullName,
                    FullName = l.FullName,
                    Name     = l.Name
                }).ToList();

                _githubCache.Setup(gh => gh.GetApiData <List <GithubApiRepository> >(UserInformation.UserName_Jared, ApiStorageConstants.APIDATA_KEY_REPOSITORIES))
                .Returns(locations);

                _harness.SetUserName(UserInformation.UserName_Jared);

                var result = _harness.Controller.Index() as JsonResult;

                var json = result.DeserializeData <List <CodeLocation> >();

                json.Count.ShouldEqual(locations.Count);
            }