Exemplo n.º 1
0
        public void DgmlService_GetFromFile_LoadNonDgmlFileShouldNotWork()
        {
            DgmlService service = new DgmlService();

            // It should throw an exception.
            service.GetFromFile("./Dgml/Examples/SampleFile.txt");
        }
Exemplo n.º 2
0
        public void DgmlService_GetFromFile_LoadInvalidShouldNotWork()
        {
            DgmlService service = new DgmlService();

            // It should throw an exception.
            service.GetFromFile("non existing file");
        }
Exemplo n.º 3
0
        public void DgmlService_GetFromFile_LoadEmptyShouldNotWork()
        {
            DgmlService service = new DgmlService();

            // It should throw an exception.
            service.GetFromFile(string.Empty);
        }
Exemplo n.º 4
0
 public void DgmlService_GetFromFile_LoadExamplesShouldWork()
 {
     foreach (string example in DgmlExamplesFilepath)
     {
         DgmlService service = new DgmlService();
         Assert.IsNotNull(service.GetFromFile(example));
     }
 }
Exemplo n.º 5
0
        public void DgmlService_SaveFile_NoChangesOnDgmlFileShouldWork()
        {
            DgmlService          service = new DgmlService();
            IEnumerator <string> exampleDgmlPathEnumerator = DgmlExamplesFilepath.GetEnumerator();

            while (exampleDgmlPathEnumerator.MoveNext())
            {
                DgmlDoc doc = service.GetFromFile(exampleDgmlPathEnumerator.Current);
                service.SaveFile(doc);

                DgmlDoc docReopened = service.GetFromFile(exampleDgmlPathEnumerator.Current);
                Assert.AreEqual <DgmlDoc>(doc, docReopened);
            }
        }
Exemplo n.º 6
0
        public void DgmlService_SaveFile_ShouldUpdateFileModifiedTime()
        {
            DgmlService          service = new DgmlService();
            IEnumerator <string> exampleDgmlPathEnumerator = DgmlExamplesFilepath.GetEnumerator();

            while (exampleDgmlPathEnumerator.MoveNext())
            {
                DateTime originalModifiedFileDateTime = File.GetLastWriteTimeUtc(exampleDgmlPathEnumerator.Current);
                DgmlDoc  doc = service.GetFromFile(exampleDgmlPathEnumerator.Current);
                service.SaveFile(doc);

                DateTime updatedModifiedFileDateTime = File.GetLastWriteTimeUtc(exampleDgmlPathEnumerator.Current);
                Assert.IsTrue(updatedModifiedFileDateTime - originalModifiedFileDateTime > TimeSpan.MinValue);
            }
        }
Exemplo n.º 7
0
        public void DgmlService_HideAllCategories_SimulateChangesShouldWork()
        {
            DgmlService          service = new DgmlService();
            IEnumerator <string> exampleDgmlPathEnumerator = DgmlExamplesFilepath.GetEnumerator();

            while (exampleDgmlPathEnumerator.MoveNext())
            {
                DgmlDoc doc         = service.GetFromFile(exampleDgmlPathEnumerator.Current);
                DgmlDoc originalDoc = (DgmlDoc)doc.Clone();

                service.HideAllCategories(doc);
                service.ShowAllCategories(originalDoc);
                service.HideAllCategories(originalDoc);

                Assert.AreEqual <DgmlDoc>(doc, originalDoc);
            }
        }
Exemplo n.º 8
0
        public void DgmlService_HideCategories_SimulateChangesShouldWork()
        {
            DgmlService          service = new DgmlService();
            IEnumerator <string> exampleDgmlPathEnumerator = DgmlExamplesFilepath.GetEnumerator();

            while (exampleDgmlPathEnumerator.MoveNext())
            {
                DgmlDoc doc         = service.GetFromFile(exampleDgmlPathEnumerator.Current);
                DgmlDoc originalDoc = (DgmlDoc)doc.Clone();

                IList <DgmlCategory> dgmlCategories = doc.Categories.Select(p => new DgmlCategory()
                {
                    Id = p.Id, Label = p.Label
                }).ToList();
                int categoryIndex = random.Next(dgmlCategories.Count);

                service.HideCategory(doc, dgmlCategories[categoryIndex]);
                Assert.AreEqual <DgmlDoc>(doc, originalDoc);
            }
        }
Exemplo n.º 9
0
        public void DgmlService_SaveFile_SaveNullShouldNotWork()
        {
            DgmlService service = new DgmlService();

            service.SaveFile(null);
        }