GetLinkedFunctionsServices_when_there_are_linked_esdService_returns_linked_list_of_esdfunctionserviceentity () { //arrange var mock = new Mock <IGetFunctionServiceXmlContent>(); mock.Setup(x => x.GetFunctionServiceXmlContent()).Returns("<Functions><Function><Identifier>1</Identifier><Label>Advice and benefits</Label><URI><![CDATA[http://id.esd.org.uk/function/1]]></URI><Description></Description><Created>2013-04-03T14:05:17.270</Created><Modified>2013-04-03T14:05:17.270</Modified><Type>Function</Type>" + "<Services><Service><Identifier>1</Identifier><Label>Advice and benefits</Label><URI><![CDATA[http://id.esd.org.uk/function/1]]></URI><Description></Description><Created>2013-04-03T14:05:17.270</Created><Modified>2013-04-03T14:05:17.270</Modified><Type>Service</Type></Service></Services>" + "</Function></Functions>"); _functionServiceXmlContent = mock.Object; var linked = new SchemaESDFunctionServiceLink() { SchemaId = 1, EsdFunctionServiceId = "Service1" }; _repository.Add(linked); var sut = new EsdFunctionService(_repository, _functionServiceXmlContent); //sut.XmlContent = "<Functions><Function><Identifier>1</Identifier><Label>Advice and benefits</Label><URI><![CDATA[http://id.esd.org.uk/function/1]]></URI><Description></Description><Created>2013-04-03T14:05:17.270</Created><Modified>2013-04-03T14:05:17.270</Modified><Type>Function</Type>" + // "<Services><Service><Identifier>1</Identifier><Label>Advice and benefits</Label><URI><![CDATA[http://id.esd.org.uk/function/1]]></URI><Description></Description><Created>2013-04-03T14:05:17.270</Created><Modified>2013-04-03T14:05:17.270</Modified><Type>Service</Type></Service></Services>" + // "</Function></Functions>" ; //sut.ProcessXmlContent(); //act var result = sut.GetLinkedFunctionsServices(1); //assert Assert.AreEqual(1, result.Count); //cleanup _repository.Delete(linked); }
public void SaveLinkedFunctionServices_will_delete_all_previous_SchemaESDFunctionServiceLink_with_given_schema_id() { //arrange var schema1 = new SchemaESDFunctionServiceLink() { SchemaId = 1 }; _repository.Add(schema1); var mock = new Mock <IGetFunctionServiceXmlContent>(); mock.Setup(x => x.GetFunctionServiceXmlContent()).Returns("<Functions><Function><Identifier>1</Identifier><Label>Advice and benefits</Label><URI><![CDATA[http://id.esd.org.uk/function/1]]></URI><Description></Description><Created>2013-04-03T14:05:17.270</Created><Modified>2013-04-03T14:05:17.270</Modified><Type>Function</Type></Function></Functions>"); _functionServiceXmlContent = mock.Object; var sut = new EsdFunctionService(_repository, _functionServiceXmlContent); //sut.XmlContent = "<xml>blank xml</xml>"; //act sut.SaveLinkedFunctionServices(1, new List <string>()); var repoResult = _repository.GetQuery().Where(x => x.SchemaId == 1).ToList(); //assert Assert.AreEqual(0, repoResult.Count); //cleanup _repository.Delete(schema1); _functionServiceXmlContent = null; }