//SetResourceNameAndId(this IDSFDataObject dataObject, IResourceCatalog catalog, string serviceName, out IResource resource) public void DataObjectExtentions_SetResourceNameAndId_GivenResourceNameIsBad_ShouldFixAndLoadResource() { //---------------Set up test pack------------------- var mockResource = new Mock <IResource>(); var mockWarewolfResource = mockResource.As <IWarewolfResource>(); var expectedResourceId = Guid.NewGuid(); mockResource.SetupGet(o => o.ResourceID).Returns(expectedResourceId); mockResource.SetupGet(o => o.ResourceName).Returns("Hello World"); mockResource.Setup(o => o.GetResourcePath(It.IsAny <Guid>())).Returns(@"Home\HelloWorld"); mockWarewolfResource.SetupGet(o => o.ResourceID).Returns(expectedResourceId); mockWarewolfResource.SetupGet(o => o.ResourceName).Returns("Hello World"); var resourceCatalog = new Mock <IResourceCatalog>(); const string ResourceId = "acb75027-ddeb-47d7-814e-a54c37247ec1"; var objSourceResourceID = ResourceId.ToGuid(); resourceCatalog.Setup(o => o.GetResource(It.IsAny <Guid>(), objSourceResourceID)).Returns(mockResource.Object); var dataObject = new Mock <IDSFDataObject>(); dataObject.SetupProperty(o => o.ResourceID); dataObject.SetupProperty(o => o.TestsResourceIds); const string ResourceName = "acb75027-ddeb-47d7-814e-a54c37247ec1.xml"; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- dataObject.Object.SetResourceNameAndId(resourceCatalog.Object, ResourceName, out var outResource); //---------------Test Result ----------------------- resourceCatalog.Verify(catalog => catalog.GetResource(It.IsAny <Guid>(), objSourceResourceID)); dataObject.VerifySet(o => o.ResourceID = expectedResourceId, Times.Exactly(1)); dataObject.VerifySet(o => o.ServiceName = "Hello World", Times.Exactly(1)); dataObject.VerifySet(o => o.SourceResourceID = expectedResourceId, Times.Exactly(1)); }