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

            AWSMetadataProvider.IsInAWS();

            Mock.Get(provider).Verify(p => p.IsInAWS(), Times.Once);
        }
        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));
        }
Exemple #7
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);
        }
Exemple #8
0
 public void SetInstance_throws_if_provider_is_null()
 {
     Assert.Throws <ArgumentNullException>(() => AWSMetadataProvider.SetInstance(null));
 }