public void AllBonesHaveAnImage()
        {
            var boneRep          = new BoneRepository();
            var boneImageWebRep  = new BoneImageWebRepository();
            var boneImageFileRep = new BoneImageFileRepository();

            var boneList = boneRep.GetBones();
            var listBoneWithImageMissing = new List <string>();

            foreach (var bone in boneList)
            {
                if (!Directory.Exists(boneImageWebRep.GetBoneImageDirectory(bone)))
                {
                    listBoneWithImageMissing.Add(bone);
                    continue;
                }

                if (!File.Exists(boneImageFileRep.GetFirstImagePath(bone)))
                {
                    listBoneWithImageMissing.Add(bone);
                }
            }

            Assert.AreEqual(0, listBoneWithImageMissing.Count,
                            string.Join(";", listBoneWithImageMissing));
        }
Esempio n. 2
0
        public void RemplirLiteDB()
        {
            var boneSeeder = new BoneRepository();
            var boneSeeds  = boneSeeder.GetBones();

            // Open database(or create if not exits)
            using (var db = Gr.GetLiteDb())
            {
                // Get bones collection
                var bones = db.GetCollection <Bone>("bones");

                // Insert new bone document (Id will be auto-incremented)
                boneSeeds.ForEach(b => bones.Upsert(new Bone()
                {
                    Name = b
                }));


                // Index document using a document property
                bones.EnsureIndex(x => x.Name);

                // Use Linq to query documents
                var results = new List <Bone>(bones.Find(x => x.Name.StartsWith("P")));

                Assert.IsNotNull(results.Find(b => b.Name == "Patella"));


                var boneImages = db.GetCollection <BoneImage>("boneImages");

                var boneImageRep = new BoneImageFileRepository();
                foreach (var boneName in boneSeeds)
                {
                    var boneImagePaths = boneImageRep.GetAllFilePath(boneName);
                    Assert.IsFalse(boneImagePaths.Count == 0);

                    Bone bone = bones.FindOne(x => x.Name == boneName);
                    foreach (string path in boneImagePaths)
                    {
                        var boneImage = new BoneImage()
                        {
                            BoneId = bone.Id, FilePath = path
                        };
                        boneImages.Insert(boneImage);
                    }
                }

                boneImages.EnsureIndex(x => x.BoneId);
            }
        }
        public void TestMethod1()
        {
            var boneListRep = new BoneRepository();
            var boneList    = boneListRep.GetBones();

            var boneImageRep = new BoneImageWebRepository();

            foreach (var bone in boneList)
            {
                if (Directory.Exists(boneImageRep.GetBoneImageDirectory(bone)))
                {
                    continue;
                }

                boneImageRep.GetImage(bone);
            }
        }
        public void TestWhatQuestionAreUnique()
        {
            var boneListRep = new BoneRepository();
            var boneList    = boneListRep.GetBones();

            List <WhatQuestion> questions = new List <WhatQuestion>();

            using (var db = Gr.GetLiteDb())
            {
                var questionsRep = db.GetCollection <WhatQuestion>("whatQuestions");
                foreach (var bone in boneList)
                {
                    var boneQuestions = new List <WhatQuestion>(questionsRep.Find(q => q.Answer == bone));

                    for (int i = 1; i < boneQuestions.Count; i++)
                    {
                        questionsRep.Delete(boneQuestions[i].Id);
                    }
                }
            }
        }
Esempio n. 5
0
        public void TestBoneList()
        {
            var boneRep = new BoneRepository();

            Assert.AreEqual(120, boneRep.GetBones().Count);
        }