コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public void SetInstance_replaces_current_provicer(IAWSMetadataProvider provider)
        {
            AWSMetadataProvider.SetInstance(provider);

            AWSMetadataProvider.IsInAWS();

            Mock.Get(provider).Verify(p => p.IsInAWS(), Times.Once);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public static void ResetInstance() => _provider = SdkMetadataProvider.Instance;
コード例 #8
0
 public static void SetInstance(IAWSMetadataProvider provider) => _provider = provider ?? throw new ArgumentNullException(nameof(provider));
コード例 #9
0
        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));
        }