public IMetadata CreateMetadata() { var environmentMetadata = _metadataBuilder.BuildEnvironmentMetadata(); var hierarchyMetadata = _metadataBuilder.BuildHierarchyMetadata(environmentMetadata); var graphMetadata = _metadataBuilder.BuildGraphMetadata(hierarchyMetadata); var metadata = new Model.Metadata(environmentMetadata, hierarchyMetadata, graphMetadata); return(metadata); }
public void BuildEnvironmentMetadata() { Mock.Arrange(() => _ipAddressByServerName.GetEnumerator()).Returns(_ipAddressByServerNameEnumerator); Mock.Arrange(() => _ipAddressByServerNameEnumerator.MoveNext()).Returns(true); Mock.Arrange(() => _ipAddressByServerNameEnumerator.Current).Returns(_keyValuePair); Mock.Arrange(() => _configurationMetadata.GetIpAddressByServerName()).Returns(_ipAddressByServerName); Mock.Arrange(() => _pingCreator.CreatePing()).Returns(_ping); Mock.Arrange(() => _ping.Send(_ipAddress, _timeout, _buffer, Arg.Matches <PingOptions>(pingOptions => pingOptions.Ttl == _pingOptions.Ttl && pingOptions.DontFragment == _pingOptions.DontFragment))).Returns(_pingReply); Mock.Arrange(() => _pingReplyEvaluator.IsIpStatusSuccess(_pingReply)).Returns(true); Mock.Arrange(() => ((IDisposable)_ping).Dispose()).When(() => true).DoInstead(() => { Mock.Arrange(() => _ipAddressByServerNameEnumerator.MoveNext()).Returns(false); Mock.Arrange(() => _ipAddressByServerNameEnumerator.Dispose()); }); var result = _testObject.BuildEnvironmentMetadata(); Assert.Equal(_localServerName, result.LocalServerName); Assert.Equal(_remoteServerNames, result.RemoteServerNames); }