public void GetSingleReverseCrossReferenceItemsTest() { // Arrange. var rcrInfo = CreateReverseCrossReferenceItem(111); var rcrEdit = CreateEditableRoot(111); SetupGetEditableRoot(ReverseCrossReferenceProcessName, rcrEdit); var retriever = new ReverseCrossReferenceItemsRetriever(ReflectionHelper.GetProperty<TestEditableRoot>(x => x.SingleRCR), _dtm); var item1 = new TestEditableRoot { SingleRCR = null }; var item2 = new TestEditableRoot { SingleRCR = rcrInfo }; // Act. TestsHelper.VerifyThrow<ArgumentNullException>(() => retriever.GetItems(null)); var result1 = retriever.GetItems(item1).ToArray(); var result2 = retriever.GetItems(item2).ToArray(); // Assert. Assert.AreEqual(0, result1.Length); Assert.AreEqual(1, result2.Length); Assert.AreSame(rcrEdit, result2[0]); }
public void GetMultiReverseCrossReferenceItemsTest() { // Arrange. var rcrInfo1 = CreateReverseCrossReferenceItem(111); var rcrInfo2 = CreateReverseCrossReferenceItem(222); var rcrList = new List<IReverseCrossReferenceItem> { rcrInfo1, rcrInfo2 }; var rcrEdit1 = CreateEditableRoot(111); var rcrEdit2 = CreateEditableRoot(222); SetupGetEditableRoot(ReverseCrossReferenceProcessName, rcrEdit1, rcrEdit2); var retriever = new ReverseCrossReferenceItemsRetriever(ReflectionHelper.GetProperty<TestEditableRoot>(x => x.MultiRCR), _dtm); var item1 = new TestEditableRoot { MultiRCR = null }; var item2 = new TestEditableRoot { MultiRCR = rcrList }; // Act. var result1 = retriever.GetItems(item1).ToArray(); var result2 = retriever.GetItems(item2).ToArray(); // Assert. Assert.AreEqual(0, result1.Length); Assert.AreEqual(2, result2.Length); Assert.AreSame(rcrEdit1, result2[0]); Assert.AreSame(rcrEdit2, result2[1]); }