Beispiel #1
0
        public void PropertyMappingPrototypeTest()
        {
            var mapping = new PropertyMapping();

            mapping.EntityType     = typeof(Person);
            mapping.PropertyType   = typeof(Guid);
            mapping.Name           = "Id";
            mapping.XmlMappingType = XmlMappingType.Attribute;

            XmlRepository.AddPropertyMappingFor(typeof(Person), mapping);

            var test = new PropertyMapping();

            test.EntityType     = typeof(Person);
            test.PropertyType   = typeof(string);
            test.Name           = "LastName";
            test.XmlMappingType = XmlMappingType.Element;

            XmlRepository.AddPropertyMappingFor(typeof(Person), test);

            var a = new PropertyMapping();

            a.EntityType     = typeof(Geek);
            a.PropertyType   = typeof(string);
            a.Name           = "SuperId";
            a.XmlMappingType = XmlMappingType.Attribute;

            XmlRepository.AddPropertyMappingFor(typeof(Geek), a);

            using (var repository = XmlRepository
                                    .Get(RepositoryFor <Person>
                                         .WithIdentity(p => p.Id)
                                         .WithDataProvider(new InMemoryDataProvider())))
            {
                var geek = new Geek
                {
                    Alias = "Jackal"
                };

                var peter = new Person
                {
                    FirstName = "Peter",
                    LastName  = "Bucher",
                    Birthday  = new DateTime(1983, 10, 17),
                    Friends   = new List <Geek>(new[] { geek, new Geek()
                                                        {
                                                            Alias = "YEAH"
                                                        } }),
                    Geek = geek
                };

                repository.SaveOnSubmit(peter);

                var loadedData = repository.LoadAll();

                Assert.That(loadedData.Count(), Is.EqualTo(1));
                Assert.That(loadedData.First().FirstName == "Peter");
                Assert.That(loadedData.First().Friends.Count, Is.EqualTo(2));
            }
        }
Beispiel #2
0
        public void sdfsdfsdf()
        {
            var repository = XmlRepository.Get(RepositoryFor <Person>
                                               .WithIdentity(p => p.Id)
                                               .WithDataProvider(new InMemoryDataProvider()));

            repository.SaveOnSubmit(new Person()
            {
                FirstName = "Peter"
            });
            repository.SaveOnSubmit(new Person()
            {
                FirstName = "Golo"
            });

            var test  = repository.LoadAll();
            var peter = repository.LoadBy(p => p.FirstName == "Peter");

            repository.DeleteOnSubmit(p => p.FirstName == "Peter");

            var test2 = repository.LoadAll();

            repository.SubmitChanges();

            repository.DataProvider = new InMemoryDataProvider();

            var sdfsdsdf = XmlRepository.Get(RepositoryFor <Person>
                                             .WithIdentity(p => p.Id));
        }
Beispiel #3
0
 internal XPathWorkbench(XmlRepository repository, SearchResultFactory searchResultFactory)
 {
     InitializeComponent();
     _repository          = repository;
     _searchResultFactory = searchResultFactory;
     SearchResults        = new ObservableCollection <SearchResult>();
 }
        protected override void Initialize()
        {
            try
            {
                base.Initialize();

                var repository = new XmlRepository();
                _container.Set<XmlRepository>(repository);

                _container.Set<SearchResultFactory>(new SearchResultFactory());

                var configuration = (XPathInformationDialogPage)GetDialogPage(typeof(XPathInformationDialogPage));
                _container.Set<IConfiguration>(configuration);

                _container.Set<StatusbarAdapter>(new StatusbarAdapter(repository, () => new XPathWriter(new[] { new AttributeFilter(configuration.AlwaysDisplayedAttributes) }), (IVsStatusbar)GetService(typeof(IVsStatusbar))));

                var commandService = (IMenuCommandService)GetService(typeof(IMenuCommandService));
                _container.Set<IMenuCommandService>(commandService);

                InitializeCommands(repository, configuration, commandService);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error in " + GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #5
0
        public GaugeSamples()
        {
            this.Title = "Gauges 101";

            List <Sample> sampleList = new XmlRepository().GetSamples();

            listView = new ListView
            {
                ItemsSource  = sampleList,
                ItemTemplate = new DataTemplate(typeof(TransparentImageCell))
                {
                    Bindings =
                    {
                        { ImageCell.TextProperty,        new Binding("Name")                 },
                        { ImageCell.DetailProperty,      new Binding("Description")          },
                        { ImageCell.ImageSourceProperty, new Binding("ThumbnailImageSource") }
                    }
                }
            };

            listView.ItemSelected += async(sender, args) =>
            {
                if (args.SelectedItem != null)
                {
                    var sample = args.SelectedItem as Sample;
                    await this.Navigation.PushAsync(GetSample(sample.SampleViewType));
                }
            };

            Content = listView;
        }
        public void GetStudentsTest2()
        {
            int count    = 17;
            int expected = new XmlRepository().GetStudents(@"C:\Users\IMullahmetov\OneDrive\Документы\Visual Studio 2017\Projects\NHibernateApp\NHibernateApp\Students.xml").Count;

            Assert.AreNotEqual(expected, count);
        }
Beispiel #7
0
 public void LoadByNullThrowsArgumentNullException()
 {
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         Assert.Throws <ArgumentNullException>(() => repository.LoadBy(null));
     }
 }
Beispiel #8
0
 ///<summary>
 /// Applies the resulted mappings with this builder globaly (application context) to all repositories.
 ///</summary>
 public void ApplyMappingsGlobal()
 {
     foreach (var mapping in this._propertyMappings)
     {
         XmlRepository.AddPropertyMappingFor(typeof(TEntity), mapping);
     }
 }
        public GaugeSamples()
        {
            this.Title = "Gauges 101";

            List<Sample> sampleList = new XmlRepository().GetSamples();

            listView = new ListView
            {
                ItemsSource = sampleList,
                ItemTemplate = new DataTemplate(typeof(TransparentImageCell))
                {
                    Bindings =
                    {
                        { ImageCell.TextProperty, new Binding("Name") },
                        { ImageCell.DetailProperty, new Binding("Description") },
                        { ImageCell.ImageSourceProperty, new Binding("ThumbnailImageSource") }
                    }
                }
            };

            listView.ItemSelected += async (sender, args) =>
                {
                    if (args.SelectedItem != null)
                    {
                        var sample =args.SelectedItem as Sample;
                        await this.Navigation.PushAsync(GetSample(sample.SampleViewType));
                    }
                };

            Content = listView;
        }
Beispiel #10
0
        public void ARepositoryCanLoadGeekFriendCollectionFromPerson()
        {
            using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
            {
                var geekFriends = new List <Geek>
                {
                    new Geek {
                        Alias = "Peter"
                    },
                    new Geek()
                    {
                        Alias = "Golo"
                    }
                };

                var robertoId             = Guid.NewGuid();
                var personWithGeekFriends = new Person
                {
                    Id        = robertoId,
                    FirstName = "Roberto", Friends = geekFriends
                };

                repository.SaveOnSubmit(personWithGeekFriends);

                Assert.That(repository.LoadAll().Count(), Is.EqualTo(1));
                Assert.That(repository.LoadBy(p => p.Id == robertoId).Friends.Count, Is.EqualTo(2));
                Assert.That(repository.LoadAll().Single().Friends[0].Alias, Is.EqualTo("Peter"));
            }
        }
        public void Update_ShouldSavesChanges_IfEntityExists()
        {
            string fileName = Guid.NewGuid().ToString("N") + ".xml";

            Guid       entityId = Guid.NewGuid();
            FakeEntity entity   = new FakeEntity()
            {
                Id = entityId, Name = entityId.ToString()
            };
            XmlRepository <FakeEntity> repository = new XmlRepository <FakeEntity>(fileName);

            repository.Add(entity);
            repository.SaveChanges();

            entity = new FakeEntity()
            {
                Id = entityId, Name = "NewValue"
            };

            repository = new XmlRepository <FakeEntity>(fileName);
            repository.Update(entity);
            repository.SaveChanges();

            repository = new XmlRepository <FakeEntity>(fileName);
            entity     = repository.Get(entityId);

            Assert.AreEqual("NewValue", entity.Name);
            File.Delete(fileName);
        }
        public void GetAll_ShouldReturnsAllAddedEntities()
        {
            string fileName = Guid.NewGuid().ToString("N") + ".xml";

            int entityCount = 3;
            IEnumerable <Guid>       entityIds = Enumerable.Range(0, entityCount).Select(x => Guid.NewGuid()).ToList();
            IEnumerable <FakeEntity> entities  = entityIds.Select(x => new FakeEntity()
            {
                Id = x, Name = x.ToString()
            });
            XmlRepository <FakeEntity> repository = new XmlRepository <FakeEntity>(fileName);

            foreach (FakeEntity entity in entities)
            {
                repository.Add(entity);
            }

            repository.SaveChanges();

            repository = new XmlRepository <FakeEntity>(fileName);
            entities   = repository.GetAll();

            Assert.AreEqual(entityCount, entities.Count());
            foreach (Guid entityId in entityIds)
            {
                Assert.IsTrue(entities.SingleOrDefault(x => x.Id == entityId && x.Name == entityId.ToString()) != null);
            }

            File.Delete(fileName);
        }
        private void InitializeCommands(XmlRepository repository, IConfiguration configuration, IMenuCommandService commandService)
        {
            var activeDocument = new ActiveDocument();

            var subMenu = CreateSubMenu(activeDocument);
            commandService.AddCommand(subMenu);

            var copyGenericXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyGenericXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyGenericXPathCommand);

            var copyAbsoluteXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyAbsoluteXPath, repository, activeDocument, () => new AbsoluteXPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyAbsoluteXPathCommand);

            var copyDistinctXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyDistinctXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes), new DistinctAttributeFilter(configuration.PreferredAttributeCandidates)}), new CommandTextFormatter());
            commandService.AddCommand(copyDistinctXPathCommand);

            var copySimplifiedXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopySimplifiedXPath, repository, activeDocument, () => new SimplifiedXPathWriter(new[] { new AttributeFilter(configuration.AlwaysDisplayedAttributes) }), new TrimCommandTextFormatter());
            commandService.AddCommand(copySimplifiedXPathCommand);

            var showXPathWorkbenchCommand = new ShowXPathWorkbenchCommand(this, commandService, Symbols.CommandIDs.ShowXPathWorkbench, repository, activeDocument);
            commandService.AddCommand(showXPathWorkbenchCommand.Command);

            var copyXmlStructureCommand = new CopyXmlStructureCommand(Symbols.CommandIDs.CopyXmlStructure, repository, activeDocument, () => new XmlStructureWriter(), new CommandTextFormatter());
            commandService.AddCommand(copyXmlStructureCommand);
        }
Beispiel #14
0
        public void MappingBuilderAbstractionIntegration()
        {
            using (var builder = XmlRepository.GetPropertyMappingBuilderFor <Person>())
            {
                builder.Map(p => p.Id).ToAttribute("sexy");
                builder.Map(p => p.LastName).ToContent();
            }

            //// builder.Map(p => p.Geek).ToElement("TESTGEEK"); ??

            string xml = "<root></root>";

            var delegateProvider = new DelegateDataProvider(() => xml, data => xml = data);

            XmlRepository.DataProvider = delegateProvider;

            using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
            {
                var person = new Person
                {
                    FirstName = "Peter&",
                    LastName  = "Bucher",
                    Geek      = new Geek
                    {
                        Alias   = "YeahAlias",
                        SuperId = "test"
                    }
                };

                repository.SaveOnSubmit(person);
                repository.SubmitChanges();

                var data = repository.LoadAll();
            }
        }
Beispiel #15
0
 public void ANewlyCreatedRepositoryDoesNotContainAnyEntities()
 {
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         this.ExecuteLoadAsserts(repository, 0, false, false);
     }
 }
Beispiel #16
0
        public DataProvider(AppMode appMode)
        {
            XmlRepository  = new XmlRepository(this);
            CommonSettings = XmlRepository.LoadCommonSettings();
            if (CommonSettings == null)
            {
                CommonSettings = new CommonSettings {
                    IsSet = false
                }
            }
            ;
            else
            {
                CommonSettings.IsSet = true;
            }
            VariablesRepository = new VariablesRepository(this);
            ObjectsRepository   = new ObjectsRepository(this);

            CommonSettings.AppMode         = appMode;
            CommonSettings.AppModeChanged += delegate { ObjectsRepository.SwitchAppMode(); };

            ProjectRepository = new ProjectRepository(this);
            DialogsManager    = new DialogsManager(this);
            TabsRepository    = new TabsRepository(this);
            WindowsManager    = new WindowsManager(this);
        }
Beispiel #17
0
        public void DataAvailableInProviderIsLoadAutomatically()
        {
            var getRepositoryThatWillBeReused = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id));

            var builder = XmlRepository.GetPropertyMappingBuilderFor <Person>();

            builder.Map(p => p.Id).ToAttribute();

            builder.ApplyMappingsGlobal();

            var prefilledInMemoryProvider = new InMemoryDataProvider(
                @"<root>
  <Person>
    <Id>c186fb12-dd38-4784-8b48-aad96a6510c4</Id>
    <LastName>Bucher</LastName>
    <FirstName>Peter</FirstName>
    <Geek>
      <Id>8f8b747e-3f16-4938-a384-980fc8aa8dd7</Id>
      <SuperId>test</SuperId>
      <Alias>Jackal</Alias>
    </Geek>
    <Friends></Friends>
    <Birthday>17.10.1983 00:00:00</Birthday>
  </Person>
</root>");

            using (var repository = XmlRepository.Get(RepositoryFor <Person>
                                                      .WithIdentity(p => p.Id)
                                                      .WithDataProvider(prefilledInMemoryProvider)))
            {
                var test = repository.LoadAll();

                Assert.That(repository.LoadAll(), Is.Not.Null);
            }
        }
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">CLI arguments</param>
        public static void Main(string[] args)
        {
            string inputFilePath  = CliArgumentsReader.GetOptionValue(args, InputFileOptions);
            string outputFilePath = CliArgumentsReader.GetOptionValue(args, OutputFileOptions);
            string namelistName   = CliArgumentsReader.GetOptionValue(args, NameOptions);
            bool   isLocked       = CliArgumentsReader.HasOption(args, IsLockedOptions);

            IShipNamesBuilder      shipNamesBuilder      = new ShipNamesBuilder();
            IShipClassNamesBuilder shipClassNamesBuilder = new ShipClassNamesBuilder();
            IFleetNamesBuilder     fleetnamesBuilder     = new FleetNamesBuilder();
            IArmyNamesBuilder      armyNamesBuilder      = new ArmyNamesBuilder();
            IPlanetNamesBuilder    planetNamesBuilder    = new PlanetNamesBuilder();
            ICharacterNamesBuilder characterNamesBuilder = new CharacterNamesBuilder();

            IFileContentBuilder fileContentBuilder = new FileContentBuilder(
                shipNamesBuilder,
                shipClassNamesBuilder,
                fleetnamesBuilder,
                armyNamesBuilder,
                planetNamesBuilder,
                characterNamesBuilder);

            IRepository <NameList> nameListRepository = new XmlRepository <NameList>(inputFilePath);
            INameListGenerator     nameListGenerator  = new NameListGenerator(fileContentBuilder, nameListRepository);

            nameListGenerator.Generate(outputFilePath, namelistName, isLocked);
        }
Beispiel #19
0
        public void XmlRepo_can_add_2_Infektion_gleiches_Land()
        {
            var repo = new XmlRepository();

            var l = new Land()
            {
                Name = "Seuchenland"
            };

            var inf1 = new Infektion()
            {
                Person = "Bernd"
            };

            inf1.Wohnort = new Region()
            {
                Name = "Pesttal", Land = l
            };
            var inf2 = new Infektion()
            {
                Person = "Bernd"
            };

            inf2.Wohnort = new Region()
            {
                Name = "Rotzberg", Land = l
            };

            repo.Add(inf1);
            repo.Add(inf2);
            repo.SaveAll();
        }
 internal XPathWorkbench(XmlRepository repository, SearchResultFactory searchResultFactory)
 {
     InitializeComponent();
     _repository = repository;
     _searchResultFactory = searchResultFactory;
     SearchResults = new ObservableCollection<SearchResult>();
 }
Beispiel #21
0
        public void XmlRepo_can_add_Infektion_with_2_Virus_MitLand()
        {
            var repo = new XmlRepository();
            var inf  = new Infektion()
            {
                Person = "Bernd"
            };

            inf.Viren.Add(new Virus()
            {
                Name = "v1"
            });
            inf.Viren.Add(new Virus()
            {
                Name = "v2"
            });
            var l = new Land()
            {
                Name = "Seuchenland"
            };

            inf.Wohnort = new Region()
            {
                Name = "Pesttal", Land = l
            };

            repo.Add(inf);
            repo.SaveAll();
        }
Beispiel #22
0
        public void XmlRepo_can_CR_Infektion_AutoFix_FluentAss()
        {
            var fn  = "AutoFix.xml";
            var fix = new Fixture();

            fix.Behaviors.Add(new OmitOnRecursionBehavior());
            for (int i = 0; i < 10; i++)
            {
                var inf = fix.Create <Infektion>();

                using (var repo = new XmlRepository(fn))
                {
                    inf.Viren.ToList().ForEach(x => repo.Add(x));
                    repo.Add(inf.Wohnort.Land);
                    repo.Add(inf.Wohnort);
                    repo.Add(inf);
                    repo.SaveAll();
                }

                using (var con = new XmlRepository(fn))
                {
                    var loaded = con.GetById <Infektion>(inf.Id);
                    loaded.Should().BeEquivalentTo(inf, c =>
                    {
                        c.Using <DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation))
                        .WhenTypeIs <DateTime>();
                        c.IgnoringCyclicReferences();
                        return(c);
                    });
                }
            }
        }
Beispiel #23
0
        public void XmlRepo_can_add_2_Infektion_und_unabhägige_Laender()
        {
            var repo = new XmlRepository();

            var inf1 = new Infektion()
            {
                Person = "Bernd"
            };
            var inf2 = new Infektion()
            {
                Person = "Brot"
            };

            var land = new Land()
            {
                Name = "Pestland"
            };
            var land2 = new Land()
            {
                Name = "Seuchenland"
            };

            land2.Region.Add(new Region()
            {
                Name = "Todeszones"
            });

            repo.Add(inf1);
            repo.Add(inf2);
            repo.Add(land);
            repo.Add(land2);
            repo.SaveAll();
        }
Beispiel #24
0
        public void Test()
        {
            var repository = new XmlRepository <XmlEntity>("D:\\Repo.xml");

            repository.Add(new XmlEntity()
            {
                Name = "Hello"
            });
            repository.Add(new XmlEntity()
            {
                Name = "Hello2"
            });

            repository.ForEach(x => Console.WriteLine(x.Name));

            var element = repository.Find(x => x.Name == "Hello").First();

            Console.WriteLine("Count: {0}\n", repository.Count);

            repository.Remove(element);

            repository.ForEach(x => Console.WriteLine(x.Name));
            Console.WriteLine("Count: {0}\n", repository.Count);

            var element2 = repository.Find(x => x.Name == "Hello2").First();

            element2.Name = "NewHelo2";

            repository.Update(element2);

            repository.ForEach(x => Console.WriteLine(x.Name));
            Console.WriteLine("Count: {0}\n", repository.Count);
        }
 protected CopyCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func<IWriter> writerProvider, ICommandTextFormatter textFormatter)
 {
     _activeDocument = activeDocument;
     Repository = repository;
     Command = new OleMenuCommand(OnInvoke, null, OnBeforeQueryStatus, new CommandID(Guid.Parse(Symbols.PackageID), id));
     WriterProvider = writerProvider;
     TextFormatter = textFormatter;
 }
Beispiel #26
0
 protected CopyCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func <IWriter> writerProvider, ICommandTextFormatter textFormatter)
 {
     Repository      = repository ?? throw new ArgumentNullException(nameof(repository));
     _activeDocument = activeDocument ?? throw new ArgumentNullException(nameof(activeDocument));
     Command         = new OleMenuCommand(OnInvoke, null, OnBeforeQueryStatus, new CommandID(Guid.Parse(Symbols.PackageID), id));
     WriterProvider  = writerProvider ?? throw new ArgumentNullException(nameof(writerProvider));
     TextFormatter   = textFormatter ?? throw new ArgumentNullException(nameof(textFormatter));
 }
    // Use this for initialization
    void Start()
    {
        // Load the world
        worldRepo = new XmlRepository <World>();
        worldData = worldRepo.GetById(new System.Guid("4e9b0641-b915-4259-b83e-c5ff96f86db9"));

        Debug.Log(worldData.Chunk.MinX() + "," + worldData.Chunk.MinY() + "," + worldData.Chunk.MaxX() + "," + worldData.Chunk.MaxY() + "," + worldData.Chunk.Width() + "," + worldData.Chunk.Height());
    }
Beispiel #28
0
 public void SaveOnSubmitNullThrowsArgumentNullException()
 {
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         Assert.Throws <ArgumentNullException>(() => repository.SaveOnSubmit((Person)null));
         Assert.Throws <ArgumentNullException>(() => repository.SaveOnSubmit((IEnumerable <Person>)null));
     }
 }
Beispiel #29
0
 public void SaveOnSubmitMultipleEntitiesSavesTheEntities()
 {
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         repository.SaveOnSubmit(new[] { this._peter, this._golo });
         this.ExecuteLoadAsserts(repository, 2, true, true);
     }
     this.ExecuteLoadAsserts(XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)), 2, true, true);
 }
        public ShowXPathWorkbenchCommand(Package package, int id, XmlRepository repository, ActiveDocument activeDocument)
        {
            _package        = package ?? throw new ArgumentNullException(nameof(package));
            _repository     = repository ?? throw new ArgumentNullException(nameof(repository));
            _activeDocument = activeDocument ?? throw new ArgumentNullException(nameof(activeDocument));
            var menuCommandID = new CommandID(Guid.Parse(Symbols.PackageID), id);

            Command = new OleMenuCommand(ShowToolWindow, null, OnBeforeQueryStatus, menuCommandID, PackageResources.ShowXPathWorkbenchCommandText);
        }
        public void Remove_ShouldThrowsException_IfIdNotExists()
        {
            string fileName = Guid.NewGuid().ToString("N") + ".xml";

            Guid entityId = Guid.NewGuid();
            XmlRepository <FakeEntity> repository = new XmlRepository <FakeEntity>(fileName);

            repository.Remove(entityId);
        }
Beispiel #32
0
 public void SaveOnSubmitAnEntitySavesTheEntity()
 {
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         repository.SaveOnSubmit(this._peter);
         this.ExecuteLoadAsserts(repository, 1, true, false);
     }
     this.ExecuteLoadAsserts(XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)), 1, true, false);
 }
        public IRepository PopulatedXmlRepository()
        {
            ObjectAssembler assembler  = new ObjectAssembler(_create);
            IRepository     repository = new XmlRepository(assembler);

            _populateRepository(repository);

            return(repository);
        }
Beispiel #34
0
 public void InitializeDataProvider()
 {
     XmlRepository.DataMapper     = new ReflectionDataMapper();
     XmlRepository.DataSerializer = new XmlDataSerializer();
     XmlRepository.DataProvider   = new InMemoryDataProvider();
     using (var repository = XmlRepository.Get(RepositoryFor <Person> .WithIdentity(p => p.Id)))
     {
         repository.DeleteAllOnSubmit();
     }
 }
        public void GetAll_ShouldReturnsEmptyCollection_IfNoData()
        {
            string fileName = Guid.NewGuid().ToString("N") + ".xml";
            XmlRepository <FakeEntity> repository = new XmlRepository <FakeEntity>(fileName);

            IEnumerable <FakeEntity> entities = repository.GetAll();

            Assert.AreEqual(0, entities.Count());
            File.Delete(fileName);
        }
Beispiel #36
0
        public void Get_GetAll_and_Update_should_throw_for_unknown_Type()
        {
            const string file = "\\somefile.xml";

            var repository = new XmlRepository(file, serializationProvider, pathResolver);

            Assert.Throws<InvalidOperationException>(() => repository.Get<MeetingRepository>(0));
            Assert.Throws<InvalidOperationException>(() => repository.GetAll<MeetingRepository>());
            Assert.Throws<InvalidOperationException>(() => repository.Update("", 0));

            new FileInfo(file).Delete();
        }
        public void ElementCountIsCorrect(string xml, string xpath, int expectedCount)
        {
            // Arrange
            var document = XDocument.Parse(xml);
            var repository = new XmlRepository();

            // Act
            var count = repository.GetNodeCount(document.Root, xpath);

            // Assert
            Assert.That(count, Is.EqualTo(expectedCount));
        }
 public ShowXPathWorkbenchCommand(Package package, IMenuCommandService commandService, int id, XmlRepository repository, ActiveDocument activeDocument)
 {
     _package = package;
     _repository = repository;
     _activeDocument = activeDocument;
     if(commandService == null)
     {
         throw new ArgumentNullException(nameof(commandService));
     }
     var menuCommandID = new CommandID(Guid.Parse(Symbols.PackageID), id);
     Command = new OleMenuCommand(ShowToolWindow, null, OnBeforeQueryStatus, menuCommandID, PackageResources.ShowXPathWorkbenchCommandText);
 }
Beispiel #39
0
		public XmlUnitOfWork(string fileName)
		{
			dataFileName = fileName;
			entities = new XmlRepository<IEntity>();

			if (!File.Exists(fileName))
				Commit();

			foreach (var wi in ReadXml())
			{
				entities.Add(wi);
			}
		}
        public void ElementIsFound(string xml, int linePosition, string expectedElementName)
        {
            // Arrange
            var repository = new XmlRepository();
            var rootElement = XElement.Parse(xml, LoadOptions.SetLineInfo);

            // Act
            var element = repository.GetElement(rootElement, 1, linePosition);
            var elementName = element == null ? string.Empty : element.Name.ToString();

            // Assert
            Assert.That(elementName, Is.EqualTo(expectedElementName));
        }
        public void AttributeIsFound(string xml, int linePosition, string expectedAttributeName)
        {
            // Arrange
            var repository = new XmlRepository();
            var rootElement = XElement.Parse(xml, LoadOptions.SetLineInfo);
            const int lineNumber = 1;

            // Act
            var attribute = repository.GetAttribute(rootElement, lineNumber, linePosition);
            var attributeName = attribute == null ? string.Empty : attribute.Name.ToString();

            // Assert
            Assert.That(attributeName, Is.EqualTo(expectedAttributeName));
        }
Beispiel #42
0
        public void SaveToXmlTest()
        {
            Card newCard = new Card
            {
                ProjectId = 123,
                Name = "namename",
                Status = CardStatus.Archived,
                SynCode = 321
            };
            newCard.AddMail("qweasda","asdadsad");
            newCard.AddPhone("12adsada3","32asads1");

            var a = new XmlRepository<Card>(newCard, "XmlInput.xml", "XmlOutput.xml");
            a.SaveToXml();
        }
        public void TestXmlRepository()
        {
            var repository = new XmlRepository(@"..\..\TestXmlRepository\Repository.xml");

            var save = repository.SaveItem(_serialisableClass);

            Assert.IsTrue(save);

            var get = repository.GetItem(_serialisableClass);

            Assert.AreEqual(get, _serialisableClass);

            var items = repository.ReadItems<TestClass>();

            Assert.IsTrue(items.Count > 0);

            var delete = repository.DeleteItem(_serialisableClass);

            Assert.IsTrue(delete);

            var missing = repository.GetItem(_serialisableClass);

            Assert.IsNull(missing);
        }
		public void SetUp()
		{
			repository = new XmlRepository<ContentVersion>(new ThreadContext(), new XmlFileSystem(new ConfigurationManagerWrapper()));
		}
 public XmlTextViewCreationListener(XmlRepository repository, StatusbarAdapter statusbar)
 {
     _repository = repository;
     _statusbar = statusbar;
 }
        public void ResetXmlOnLoad()
        {
            // Arrange
            var repository = new XmlRepository();
            repository.LoadXml("<this-is-xml />");

            // Act
            repository.LoadXml("This is not XML.");

            // Assert
            Assert.That(repository.GetRootElement(), Is.Null);
        }
 public CopyXmlStructureCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func<IWriter> writerProvider, ICommandTextFormatter textFormatter)
     : base(id, repository, activeDocument, writerProvider, textFormatter)
 {
 }
Beispiel #48
0
 protected void given_repository()
 {
     Repository = new XmlRepository(new InMemoryNavigator(), new IExportBuilder[0]);
 }
        public void MultiLineElementAttributeIsFound(int lineNumber, int linePosition, string expectedAttributeName)
        {
            // Arrange
            var xml = @"<configuration xmlns:patch=""http://www.sitecore.net/xmlconfig/"">
                              <sitecore>
                                <sites>
                                  <site name=""website"">
                                    <patch:attribute name=""rootPath"">/sitecore/content/Original</patch:attribute>
                                  </site>

                                  <site name=""OtherWebsite"" patch:after=""site[@name='website']""
                                        virtualFolder=""/""
                                        physicalFolder=""/""
                                        rootPath=""/sitecore/content/OtherWebsite""
                                        startItem=""/Home""
                                        database=""web""
                                        domain=""extranet""
                                        allowDebug=""true""
                                        cacheHtml=""true""
                                        htmlCacheSize=""10MB""
                                        enablePreview=""true""
                                        enableWebEdit=""true""
                                        enableDebugger=""true""
                                        disableClientData=""false""/>
                                </sites>
                              </sitecore>
                            </configuration>";
            var rootElement = XElement.Parse(xml, LoadOptions.SetLineInfo);
            var siteElement = rootElement.DescendantsAndSelf("site").LastOrDefault();
            var repository = new XmlRepository();

            // Act
            var attribute = repository.GetAttribute(siteElement, lineNumber, linePosition);
            var attributeName = attribute == null ? string.Empty : attribute.Name.ToString();

            // Assert
            Assert.That(attributeName, Is.EqualTo(expectedAttributeName));
        }
 public StatusbarAdapter(XmlRepository repository, Func<XPathWriter> writerProvider, IVsStatusbar statusbar)
 {
     _repository = repository;
     _writerProvider = writerProvider;
     _statusbar = statusbar;
 }