public void RemoveDependency_XmlDependencyIsRemoved_DependencyIsRemovedFromChangeTrackingService() { var dependencies = _InitializeViewModelDependencies(); var changeTrackingServiceMock = dependencies.GetEntry <Mock <IChangeTrackingService> >(); // create the component var xmlComponentStub = new Mock <IXmlComponent>(); // create a dependency var xmlDependencyStub = new Mock <IXmlDependency>(); var xmlDependencyList = new List <IXmlDependency> { xmlDependencyStub.Object }; xmlComponentStub.Setup(o => o.Dependencies) .Returns(xmlDependencyList); // act var target = new XmlComponentViewModel(xmlComponentStub.Object); var firstDependency = target.GetDependencies().First(); // make sure the dependency has a change so it is tracked by the change tracking service firstDependency.SetChanged(); // now remove the dependency target.RemoveDependency(firstDependency); // make sure the dependency was removed changeTrackingServiceMock.Verify(o => o.Remove(firstDependency)); }
public void IsChanged_XmlDependencyIsRemoved_IsChangedIsTrue() { _InitializeViewModelDependencies(); // create the component var xmlComponentStub = new Mock <IXmlComponent>(); // create a dependency var xmlDependencyStub = new Mock <IXmlDependency>(); var xmlDependencyStub2 = new Mock <IXmlDependency>(); var xmlDependencyList = new List <IXmlDependency> { xmlDependencyStub.Object, xmlDependencyStub2.Object }; xmlComponentStub.Setup(o => o.Dependencies) .Returns(xmlDependencyList); var target = new XmlComponentViewModel(xmlComponentStub.Object); var firstDependency = target.GetDependencies().First(); target.RemoveDependency(firstDependency); Assert.IsTrue(target.IsChanged); }