<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using LazyStorage.InMemory;
using LazyStorage.Xml;
using Xunit;

namespace LazyStorage.Tests.Xml
{
    public class XmlRepositoryTests
    {
        [Fact]
        public void CanAddToRepo()
        {
            var repo = new XmlRepository<TestObject>(new XDocument(new XElement("Root")));
            var obj = new TestObject();

            repo.Upsert(obj);
            
            var repoObj = repo.Get().Single();

            Assert.True(repoObj.ContentEquals(obj), "The object returned does not match the one added");
        }

        [Fact]
        public void CanGetByLinq()
        {
            var repo = new XmlRepository<TestObject>(new XDocument(new XElement("Root")));
            var objOne = new TestObject {Name = "one"};
            var objTwo = new TestObject {Name = "two"};

            repo.Upsert(objOne);
            repo.Upsert(objTwo);

            var result = repo.Get(x => x.Name == "one").SingleOrDefault();

            Assert.NotNull(result);
            Assert.True(result.Equals(objOne), "The object could not be retrieved from the repository");
        }
    }
}<commit_msg>Red: Can get from Xml by Id<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using LazyStorage.InMemory;
using LazyStorage.Xml;
using Xunit;

namespace LazyStorage.Tests.Xml
{
    public class XmlRepositoryTests
    {
        [Fact]
        public void CanAddToRepo()
        {
            var repo = new XmlRepository<TestObject>(new XDocument(new XElement("Root")));
            var obj = new TestObject();

            repo.Upsert(obj);
            
            var repoObj = repo.Get().Single();

            Assert.True(repoObj.ContentEquals(obj), "The object returned does not match the one added");
        }

        [Fact]
        public void CanGetById()
        {
            var repo = new XmlRepository<TestObject>(new XDocument(new XElement("Root")));
            var obj = new TestObject();

            repo.Upsert(obj);

            Assert.NotNull(repo.GetById(1));
        }

        [Fact]
        public void CanGetByLinq()
        {
            var repo = new XmlRepository<TestObject>(new XDocument(new XElement("Root")));
            var objOne = new TestObject {Name = "one"};
            var objTwo = new TestObject {Name = "two"};

            repo.Upsert(objOne);
            repo.Upsert(objTwo);

            var result = repo.Get(x => x.Name == "one").SingleOrDefault();

            Assert.NotNull(result);
            Assert.True(result.Equals(objOne), "The object could not be retrieved from the repository");
        }
    }
}
{'fraction_non_alphanumeric': 0.11295681063122924, 'fraction_numerical': 0.00036913990402362494, 'mean_word_length': 2.1257208765859286, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '505038', 'n_tokens_mistral': 757, 'n_tokens_neox': 746, 'n_words': 192}