public void AvailabilityZone_forwards_to_provider(IAWSMetadataProvider provider, string availabilityZone) { Mock.Get(provider).Setup(p => p.GetAvailabilityZone()).Returns(availabilityZone); AWSMetadataProvider.SetInstance(provider); Assert.That(AWSMetadataProvider.GetAvailabilityZone(), Is.EqualTo(availabilityZone)); }
public void AmiId_forwards_to_provider(IAWSMetadataProvider provider, string amiId) { Mock.Get(provider).Setup(p => p.GetAmiId()).Returns(amiId); AWSMetadataProvider.SetInstance(provider); Assert.That(AWSMetadataProvider.GetAmiId(), Is.EqualTo(amiId)); }
public void IsInAWS_forwards_to_provider(bool isInAws, IAWSMetadataProvider provider) { Mock.Get(provider).Setup(p => p.IsInAWS()).Returns(isInAws); AWSMetadataProvider.SetInstance(provider); Assert.That(AWSMetadataProvider.IsInAWS(), Is.EqualTo(isInAws)); }
public void InstanceType_forwards_to_provider(IAWSMetadataProvider provider, string instanceType) { Mock.Get(provider).Setup(p => p.GetInstanceType()).Returns(instanceType).Verifiable(); AWSMetadataProvider.SetInstance(provider); Assert.That(AWSMetadataProvider.GetInstanceType(), Is.EqualTo(instanceType)); }
public void SetInstance_replaces_current_provicer(IAWSMetadataProvider provider) { AWSMetadataProvider.SetInstance(provider); AWSMetadataProvider.IsInAWS(); Mock.Get(provider).Verify(p => p.IsInAWS(), Times.Once); }
public void Reset_sets_provider_to_default(IAWSMetadataProvider provider) { AWSMetadataProvider.SetInstance(provider); AWSMetadataProvider.IsInAWS(); Mock.Get(provider).Verify(p => p.IsInAWS(), Times.Once); Mock.Get(provider).ResetCalls(); AWSMetadataProvider.ResetInstance(); AWSMetadataProvider.GetInstanceId(); Mock.Get(provider).Verify(p => p.IsInAWS(), Times.Never); }
public static void ResetInstance() => _provider = SdkMetadataProvider.Instance;
public static void SetInstance(IAWSMetadataProvider provider) => _provider = provider ?? throw new ArgumentNullException(nameof(provider));
public async Task Dimensions_are_added_if_in_AWS(bool isInAws, EC2MetricCollector sut, IAWSMetadataProvider provider, IDictionary <IMetricDimension, object> dimensions, IDictionary <IMetricValue, IValue> metrics) { Mock.Get(provider).Setup(p => p.IsInAWS()).Returns(isInAws); AWSMetadataProvider.SetInstance(provider); await sut.OnActionExecutingAsync(dimensions, metrics); Assert.That(dimensions.ContainsKey(EC2MetadataDimensions.InstanceId), Is.EqualTo(isInAws)); Assert.That(dimensions.ContainsKey(EC2MetadataDimensions.AmiId), Is.EqualTo(isInAws)); Assert.That(dimensions.ContainsKey(EC2MetadataDimensions.AvailabilityZone), Is.EqualTo(isInAws)); Assert.That(dimensions.ContainsKey(EC2MetadataDimensions.InstanceType), Is.EqualTo(isInAws)); }