public void Should_perform_array_translations() { XNamespace json = "http://james.newtonking.com/projects/json"; var xelement = new XElement( "MyArray", new XElement("A", new XElement("B", "1"), new XElement("B", "2"), new XElement("B", "3"))); var item = new XmlLookupWorkItem(xelement) { ResourceName = "Array" }; Console.WriteLine(item.LookupXElement); var success = _mapStep.Process(item).Result; Assert.IsTrue(success); Console.WriteLine(item.GetByExampleXElement); var expected = new XElement( "myArray", new XElement( "a", new XAttribute(json + "Array", true), new XElement("b", "1"), new XElement("b", "2"), new XElement("b", "3"))); Assert.AreEqual(expected.ToString(), item.GetByExampleXElement.ToString()); }
public void Should_correctly_build_lookup_property_dictionary_from_LookupXml() { var xelement = XElement.Parse(_educationOrganizationReferenceElement); var item = new XmlLookupWorkItem(xelement) { ResourceName = "EducationOrganization", LookupName = "EducationOrganizationLookup", IdentityName = "EducationOrganizationIdentity" }; var step = new EducationOrganizationCacheLookupStep( new TestEducationOrganizationIdentityCache( new List <int> { 9999 })); step.Process(item); Assert.AreEqual(_lookupPropertyValuesByName.Count, 4); foreach (var expectedKey in new List <string> { "EducationOrganizationCategory", "EducationOrganizationIdentificationSystem", "IdentificationCode", "NameOfInstitution" }) { Assert.IsTrue(_lookupPropertyValuesByName.ContainsKey(expectedKey)); } }
public void Should_not_set_IdentityXElement_if_no_EdOrg_is_found_in_cache() { var xelement = XElement.Parse(_educationOrganizationReferenceElement); var item = new XmlLookupWorkItem(xelement) { ResourceName = "EducationOrganization", LookupName = "EducationOrganizationLookup", IdentityName = "EducationOrganizationIdentity" }; var step = new EducationOrganizationCacheLookupStep( new TestEducationOrganizationIdentityCache(new List <int>())); step.Process(item); Assert.IsNull(item.IdentityXElement); }
public void Should_perform_reference_type_translations() { var xelement = new XElement("Foo", new XElement("FooDescriptor", "NameSpace#descriptor")); var item = new XmlLookupWorkItem(xelement) { ResourceName = "Descriptor" }; Console.WriteLine(item.LookupXElement); var success = _mapStep.Process(item).Result; Assert.IsTrue(success); Console.WriteLine(item.GetByExampleXElement); var expected = new XElement("foo", new XElement("fooDescriptor", "NameSpace#descriptor")); Assert.AreEqual(expected.ToString(), item.GetByExampleXElement.ToString()); }
public void Should_only_process_education_organization_lookups() { var xelement = XElement.Parse(_educationOrganizationReferenceElement); var item = new XmlLookupWorkItem(xelement) { ResourceName = "EducationOrganization", LookupName = "NotEducationOrganizationLookup", IdentityName = "EducationOrganizationIdentity" }; var step = new EducationOrganizationCacheLookupStep( new TestEducationOrganizationIdentityCache( new List <int> { 123, 456 })); step.Process(item); Assert.IsNull(item.IdentityXElement); }
public void Should_not_set_IdentityXElement_more_than_1_edorg_is_found_in_cache_for_provided_lookup_columns() { var xelement = XElement.Parse(_educationOrganizationReferenceElement); var item = new XmlLookupWorkItem(xelement) { ResourceName = "EducationOrganization", LookupName = "EducationOrganizationLookup", IdentityName = "EducationOrganizationIdentity" }; var step = new EducationOrganizationCacheLookupStep( new TestEducationOrganizationIdentityCache( new List <int> { 123, 456 })); step.Process(item); Assert.IsNull(item.IdentityXElement); }
public void Should_perform_simple_element_name_translations() { var xelement = new XElement( "Abc", new XElement("A", "hello"), new XElement("B", "world"), new XElement("C", "!!!")); var item = new XmlLookupWorkItem(xelement) { ResourceName = "Simple" }; Console.WriteLine(item.LookupXElement); var success = _mapStep.Process(item).Result; Assert.IsTrue(success); Console.WriteLine(item.GetByExampleXElement); var expected = new XElement( "alphabet", new XElement("a", "hello"), new XElement("b", "world"), new XElement("c", "!!!")); Assert.AreEqual(expected.ToString(), item.GetByExampleXElement.ToString()); }
public void Should_correctly_set_IdentityXElement_if_EdOrg_found_in_identity_cache() { var xelement = XElement.Parse(_educationOrganizationReferenceElement); var item = new XmlLookupWorkItem(xelement) { ResourceName = "EducationOrganization", LookupName = "EducationOrganizationLookup", IdentityName = "EducationOrganizationIdentity" }; var step = new EducationOrganizationCacheLookupStep( new TestEducationOrganizationIdentityCache( new List <int> { 9999 })); step.Process(item); Assert.AreEqual( item.IdentityXElement.ToString(), new XElement(item.IdentityName, new XElement($"{item.ResourceName}Id", 9999)).ToString()); }